使用 Nexus 搭建私有仓库

Nexus3

安装

  • Dockerfile
From sonatype/nexus3
  • docker-composer.yml
version: "3.7"
services:
  verdaccio:
    image: registry.cn-hangzhou.aliyuncs.com/lewis/npm-nexus
    restart: always
    environment:
      - NODE_ENV=production
    ports:
      - 8081:8018
    volumes:
      - nexus-data:/nexus-data
    container_name: "docker-npm-nexus"

volumes:
  nexus-data:
  • 启动
# 配置开机启动
docker-compose up -d

配置角色和用户

  • 配置角色

  • 配置用户

配置 npm 仓库

  • 新建 npm-proxy(仓库代理)

  • 新建 npm-hosted(私有仓库)

  • 新建 npm-group-all

  • 本地配置
# 安装 nrm
nrm add mono http://xxx/repository/npm-group-all/
nrm use mono
npm login --scope=@monogogo `(输入上面配置 User 时设置的用户名密码)`
# done

配置 docker 仓库

  • 新建 docker-proxy

  • 新建 docker-hosted

  • 新建 docker-group

  • 使用方式
  1. 配置
    • windows


- centos7

cd /etc/docker/daemon.json
{
  "registry-mirrors": [],
  "insecure-registries": [
    "192.168.137.236:8082"
  ],
  "debug": true,
  "experimental": false
}

restart

systemctl restart docker
  1. login
docker login -u ${user} -p ${password} 192.168.137.236:8082
  1. search
docker search 192.168.137.236:8082/nginx
  1. pull
docker pull 192.168.137.236:8082/nginx
  1. 被缓存过的镜像都会保存在这里

最后

Nexus还有其他很多实用仓库,比如yum、python、npm、maven等。非常好用!非常直观简单!