建构docker私有仓库Registry

1. 创建认证信息

mkdir /etc/docker/redistry/auth
docker run --entrypoint htpasswd httpd:2 -Bbn registry )P:?>LO(elink136 > /etc/docker/registry/auth/htpasswd

2. 创建镜像

registry:
  restart: always
  image: registry:latest
  container_name: registry
  ports:
    - 5000:5000
  environment:
    REGISTRY_AUTH: htpasswd
    REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
    REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
  volumes:
    - /etc/docker/registry/auth:/auth
    - /etc/docker/registry/:/etc/docker/registry

3. 运行

docker run --entrypoint htpasswd httpd:2 -Bbn registry )P:?>LO(elink136 > /etc/docker/registry/auth/htpasswd

4.配置客户机Registry信任

vim /etc/docker/daemon.json  #修改Docker的Daemon配置
添加:insecure-registries字段,对需要的Registry进行信任操作
{
  "insecure-registries": ["172.##.##.###:5000"]
}
重启配置生效
systemctl restart docker
  • 注意低版本Linux环境需要进行一下操作: 修改docker配置文件
vim /etc/sysconfig/docker
添加:
# /etc/sysconfig/docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d

other_args="--insecure-registry=########"

5.客户机登录Registry

docker login -u username -p password registry_host #登录Registry
#高版本不允许使用-p参数使用如下登陆方式:
echo password | docker login -u username --password-stdin registry_host

建构docker私有仓库Registry
https://www.lingyepro.com/archives/390
作者
零叶独舞
发布于
2023年01月02日
许可协议