Docker Registry 使用密码
# 生成访问密码
docker run --entrypoint htpasswd httpd:2 -Bbn admin password > htpasswd
# 创建 registry 并且绑定密码
docker run -d -p 5000:5000 --restart=always --name docker-registry -v /etc/htpasswd:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd registry:2
Docker 安装
# 需要配置 docker-ce 源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 配置非信任镜像仓库
[root@localhost]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://ustc-edu-cn.mirror.aliyuncs.com",
"https://mirror.ccs.tencentyun.com",
"https://dockerhub.azk8s.cn",
"https://registry.cn-hangzhou.aliyuncs.com"
],
"insecure-registries": [
"127.0.0.1:5000"
]
}
# docker 登录
docker login http://127.0.0.1:5000