- 简单介绍 docker registry 部署的相关知识
- 参考文献:https://github.com/docker/distribution/blob/master/docs/configuration.md
- 查看配置文件:
cd registry2_deploy
cat scripts/registry-config.sh
- 配置文件内容如下:
#!/bin/bash
REGISTRY_NAME="registry"
REGISTRY_ADDR="my.registry.com"
REGISTRY_IP="192.168.1.68"
REGISTRY_USERNAME="test"
REGISTRY_PASSWORD="password"
echo "REGISTRY_NAME="$REGISTRY_NAME
echo "REGISTRY_ADDR="$REGISTRY_ADDR
echo "REGISTRY_IP="$REGISTRY_IP
echo -e "REGISTRY_USERNAME=\c"
echo -n $REGISTRY_USERNAME | base64
echo -e "REGISTRY_PASSWORD=\c"
echo -n $REGISTRY_PASSWORD | base64
- 修改上述各个变量为私有 registry 对应的值
- 依次为设置
容器名称
、域名
、IP 地址
、登陆用户名
、登陆密码
- 以 http 方式启动:
cd registry2_deploy
sudo ./scripts/run-local-http.sh start
- 停止服务
cd registry2_deploy
sudo ./scripts/run-local-http.sh stop
- 重启服务
cd registry2_deploy
sudo ./scripts/run-local-http.sh restart
- 以 https 方式启动:
cd registry2_deploy
sudo ./scripts/run-local-http.sh start
- 停止服务
cd registry2_deploy
sudo ./scripts/run-local-http.sh stop
- 重启服务
cd registry2_deploy
sudo ./scripts/run-local-http.sh restart
- 为了让各个节点可以访问到私有的 registry,需要修改
/etc/hosts
、/etc/docker/daemon.json
等文件 - 在
/etc/hosts
中追加私有 registry 的 IP 到域名的映射
192.168.1.68 my.registry.com
- 在
/etc/docker/daemon.json
中添加insecure-registries
字段,值为 ${域名}:${监听端口} -
/etc/docker/daemon.json
示例如下:
{
"insecure-registries": ["my.registry.com:5000"],
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com",
"https://pee6w651.mirror.aliyuncs.com"
]
}
- 重启 docker 服务:
sudo systemctl daemon-reload && sudo systemctl restart docker.service
- 登陆验证:
sudo docker login my.registry.com:5000 -u test -p password