部署私有仓库

Docker Registry

  • 拉取 Docker 官方仓库镜像

   以下选用 192.168.2.80 作为 Humpback 私有仓库服务器。

  1. 192.168.2.80
  2. $ mkdir -p /var/lib/registry
  3. $ docker pull registry:2.5.1
  • 启动仓库服务

   请将配置文件拷贝到 /etc/docker/registry/config.yml,关于仓库配置说明请参见 configuration.md

   仓库若要支持跨域访问,请将 config.ymlhttp 项改为如下:

  1. http:
  2. addr: :5000
  3. secret: abcdfg
  4. headers:
  5. X-Content-Type-Options: [nosniff]
  6. Access-Control-Allow-Headers: ['Origin,Accept,Content-Type,Authorization']
  7. Access-Control-Allow-Origin: ['*']
  8. Access-Control-Allow-Methods: ['GET,POST,PUT,DELETE']

   启动仓库

  1. $ docker run -d -p 5000:5000 --restart=always \
  2. -v /var/lib/registry/:/var/lib/registry/ \
  3. -v /etc/docker/registry/config.yml:/etc/docker/registry/config.yml \
  4. --name registry \
  5. registry:2.6.2
  • 检查启动状态,若 _catalog 接口能正常访问,证明仓库启动成功。
  1. $ docker ps -a
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. a0e4c87eef5b registry:2.6.2 "/entrypoint.sh /etc/" 15 minutes ago 45 seconds ago 0.0.0.0:5000->5000/tcp registry
  4. $ curl http://192.168.2.80:5000/v2/_catalog
  5. {"repositories":[]}