拉取下载
docker pull registry
docker-compose.yml配置编写
version: '3.1'
services:
# docker镜像管理平台
registry:
image: registry
restart: always
container_name: registry
ports:
- 5000:5000
volumes:
- /usr/local/docker/registry/data:/var/lib/registry
frontend:
image: konradkleine/docker-registry-frontend:v2
restart: always
container_name: docker-registry-frontend
ports:
- 5080:80
volumes:
- ./certs/frontend.crt:/etc/apache2/server.crt:ro
- ./certs/frontend.key:/etc/apache2/server.key:ro
environment:
- ENV_DOCKER_REGISTRY_HOST=192.168.10.169
- ENV_DOCKER_REGISTRY_PORT=5000
查看是否启动
http://192.168.10.10:5000/v2/
配置客户端
vim /etc/docker/daemon.json
加入"insecure-registries": ["192.168.10.169:5000"] 注意ip地址需要修改
{
"registry-mirrors": [
"https://fy707np5.mirror.aliyuncs.com",
"https://mirror.ccs.tencentyun.com",
"http://f1361db2.m.daocloud.io",
"https://3laho3y3.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com",
"https://registry.docker-cn.com"
],
"insecure-registries": [
"192.168.10.10:5000"
]
}
刷新配置:systemctl daemon-reload
重启docker :systemctl restart docker
查看配置是否生效: docker info
使用
docker tag tomcat 192.168.10.169:5000/tomcat
docker push 192.168.10.169:5000/tomcat
查看tomcat是否推送成功:http://192.168.10.169:5000/v2/_catalog
查看tomcat列表:http://192.168.10.169:5000/v2/tomcat/tags/list
查看界面:http://192.168.10.169:8080/
远程推送到服务器
docker push 100.97.82.45:5000/zuul
如果报错:received unexpected HTTP status: 500 Internal Server Error
关闭SELinux
getenforce # 查看SELinux状态
setenforce 0 #关闭SELinux
#长期关闭
vim /etc/sysconfig/selinux
SELINUX=enforcing 改为 SELINUX=disabled
配置客户端
vim /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --registry-mirror=https://jxus37ac.mirror.aliyuncs.com --insecure-registry 192.168.10.10:5000 tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
systemctl daemon-reload #加载配置
service docker restart #重启docker