创建服务
version: "3"
services:
registry:
image: registry
container_name: registry
privileged: true
volumes:
- ./htpasswd:/auth/htpasswd #步骤2创建
- ./registry:/var/lib/registry
- /etc/localtime:/etc/localtime
ports:
- 10020:5000
environment:
- REGISTRY_AUTH=htpasswd
- REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd
- REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm
- REGISTRY_STORAGE_DELETE_ENABLED=true
restart: always
生成账号密码:root 123456
docker run --entrypoint htpasswd registry:latest -Bbn root 123456 >> ./htpasswd
客户端使用
{
"insecure-registries": ["192.168.0.2:10020"]
}
常用命令
docker login 192.168.0.2:10020 #登录容器
docker logout 192.168.0.2:10020 #退出登录
docker tag 66212d86b283 192.168.0.2:10020/redis:latest #新增tag
docker push 192.168.0.2:10020/redis:latest #推送镜像