docker-compose.yml
version: '3.1'
services:
registry:
image: registry
restart: always
container_name: registry
ports:
- 5000:5000
volumes:
- /usr/local/docker/registry/data:/var/lib/registry #容器持久化
--------------------------------以下是带前端的docker 仓库-------------------------------
version: '3.1'
services:
registry:
image: registry
restart: always
container_name: registry
ports:
- 5000:5000
volumes:
- /usr/local/docker/registry/data:/var/lib/registry
fronttend:
image: konradkleine/docker-registry-frontend:v2
ports:
- 8080: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.106.130
- ENV_DOCKER_REGISTRY_PORT=5000
访问:ip:5000/v2/ 测试是否成功 若返回空json串 成功!
想让 docker pull 镜像 先去docker 私服找镜像
先配置 /etc/docker/daemon.json中加入
{
"insecure-registries":[
"192.168.106.132:5000" #192.168.106.132处为linux ip
]
}
别忘了重启docker 保证生效
systemctl restart docker
测试是否配置docker私服成功, 如果显示以下配置的ip 则配置私服成功
docker info
上传镜像至我们的镜像私服
docker tag tomcat 192.168.106.130:5000/tomcat #标记本地镜像,并指向仓库
docker push 192.168.106.130:5000/tomcat #将镜像推送至仓库
查看仓库所有镜像
访问 http://192.168.106.130:5000/v2/_catalog
查看指定镜像的版本
访问 http://192.168.106.130:5000/v2/tomcat/tags/list
拉取仓库镜像
docker pull 192.168.106.130:5000/tomcat
删除仓库镜像
docker rmi 192.168.106.130:5000/tomcat