欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Docker私有仓库搭建

程序员文章站 2024-03-12 23:56:03
...

Docker私有仓库搭建

1.安装

mkdir -p /data/docker-registry/auth
mkdir -p /data/docker-registry/config
docker pull registry
# 创建用户
docker run --entrypoint htpasswd registry -Bbn lynnyq lynnyq  >> /data/docker-registry/auth/htpasswd
# 配置文件,设置配置文件,启用删除镜像功能(也可以不启用,看业务需要,修改 storage - delete - enable 为 false 即可)
vim /data/docker-registry/config/config.yml
  • config.yml
version: 0.1
log:
  fields:
    service: registry
storage:
  delete:
    enabled: true
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
threshold: 3

2.启动服务

docker run -d -p 5000:5000 --restart=always  --name=registry\
  -v /data/docker-registry/config/:/etc/docker/registry/ \
  -v /data/docker-registry/auth/:/auth/ \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
  -v /data/docker-registry/:/var/lib/registry/ \
registry
  • 开启非ssl认证仓库
vim /etc/docker/daemon.json

{
    "data-root": "/data/docker-data",
    "storage-driver": "overlay",
    "registry-mirrors": ["https://registry.docker-cn.com"],
    "bip": "192.168.1.1/24",
    "insecure-registries":[
        "localhost:5000"
    ]
}
# systemctl daemon-reload
# systemctl restart docker
  • 上传镜像
docker login localhost:5000
docker tag epp_data_center localhost:5000/epp/epp_data_center:v0.01
docker push localhost:5000/epp/epp_data_center
  • 查看镜像
[root@hillin-cpp-dev-3 epp_data_center]# curl -u lynnyq:lynnyq http://localhost:5000/v2/_catalog
{"repositories":["epp/epp_data_center"]}

[root@hillin-cpp-dev-3 epp_data_center]# curl -u lynnyq:lynnyq http://localhost:5000/v2/epp/epp_data_center/tags/list
{"name":"epp/epp_data_center","tags":["v0.01"]}
[root@localhost ~]# curl -u lynnyq:lynnyq https://host/v2/_catalog
{"repositories":["epp/epp_data_center"]}
[root@localhost ~]# curl -u lynnyq:lynnyq https://host/v2/epp/epp_data_center/tags/list
{"name":"epp/epp_data_center","tags":["v0.01"]}
  • 拉取镜像
[root@localhost ~]# docker login host
Username: lynnyq
Password: 
Login Succeeded
[root@localhost ~]# docker pull host/epp/epp_data_center:v0.01
相关标签: Docker 私有仓库

上一篇: C. Songs Compression

下一篇: