Docker搭建有UI的私有镜像仓库
一、使用这个docker-compose.yml文件:
version: '3'
services:
registry-ui:
image: joxit/docker-registry-ui:2.5.7-debian
restart: always
ports:
- 81:80
environment:
- SINGLE_REGISTRY=true
- REGISTRY_TITLE=Att Docker Registry UI
- DELETE_IMAGES=true
- SHOW_CONTENT_DIGEST=true
- NGINX_PROXY_PASS_URL=http://registry-server:5000
- SHOW_CATALOG_NB_TAGS=true
- CATALOG_MIN_BRANCHES=1
- CATALOG_MAX_BRANCHES=1
- TAGLIST_PAGE_SIZE=100
- REGISTRY_SECURED=false
- CATALOG_ELEMENTS_LIMIT=1000
container_name: registry-ui
registry-server:
image: registry
restart: always
environment:
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '[http://192.168.8.20:81]'
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Methods: '[HEAD,GET,OPTIONS,DELETE]'
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Credentials: '[true]'
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Headers: '[Authorization,Accept,Cache-Control]'
REGISTRY_HTTP_HEADERS_Access-Control-Expose-Headers: '[Docker-Content-Digest]'
REGISTRY_STORAGE_DELETE_ENABLED: 'true'
volumes:
- /exthd/registry-data:/var/lib/registry
container_name: registry-server
二、配置Docker信任地址
私服采用的是http协议,默认不被Docker信任,所以需要做一个配置:
vi /etc/docker/daemon.json
需要将 http://192.168.3.128 替换为你自己的 ip
“insecure-registries”:[“http://192.168.3.128:8080”]
需要注意的是,别忘了需要写一个逗号
重加载
#systemctl daemon-reload
重启docker
#systemctl restart docker
三、推送镜像
1.tag本地镜像
docker tag nginx:latest 192.168.3.128:8080/nginx:1.0
2.推送镜像
docker push 192.168.3.128:8080/nginx:1.0
四、拉取镜像
1.先把之前的删除掉
docker rmi 192.168.3.128:8080/nginx:1.0
docker rmi nginx:latest # 如果镜像正在被容器使用,可以使用 -f 选项进行强制删除
2.拉取镜像
docker pull 192.168.3.128:8080/nginx:1.0