私有仓库服务端:12.40
[root@centos7_golang ~]# docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry-dev --name docker-registry registry:2.4
[root@centos7_golang ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cebb252856b1 registry:2.4 "/bin/registry serve " 3 seconds ago Up 2 seconds 0.0.0.0:5000->5000/tcp docker-registry
允许在同一台机器上使用pull和push操作,此步骤需在客户端配置,然现在这台即是服务器端又是客户端
[root@centos7_golang ~]# vi /usr/lib/systemd/system/docker.service
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network.target docker.socket Requires=docker.socket #ExecStart=/usr/bin/docker daemon -H fd:// #Delegate=yes # [Service] Type=notify NotifyAccess=all EnvironmentFile=-/etc/sysconfig/docker Environment=GOTRACEBACK=crash ExecStart=/bin/sh -c '/usr/bin/docker daemon $OPTIONS' LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity MountFlags=slave TimeoutStartSec=0 Restart=on-failure StandardOutput=null StandardError=null [Install] WantedBy=multi-user.target
[root@RegistryPortus ~]# grep -v "^#" /etc/sysconfig/docker
OPTIONS='--selinux-enabled --insecure-registry 172.16.160.45:5000'
DOCKER_CERT_PATH=/etc/docker
或修改/usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/docker daemon --insecure-registry 172.16.160.45:5000 $OPTIONS' $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY
[root@centos7_golang ~]# systemctl daemon-reload
[root@centos7_golang ~]# systemctl restart docker
[root@centos7_golang ~]# docker start docker-registry
[root@centos7_golang ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cebb252856b1 registry:2.4 "/bin/registry serve " 8 minutes ago Up 4 seconds 0.0.0.0:5000->5000/tcp docker-registry
#上传镜像至仓库
[root@centos7_golang ~]# docker pull nginx
[root@centos7_golang ~]# docker tag nginx 192.168.12.40:5000/nginx
[root@centos7_golang ~]# docker push 192.168.12.40:5000/nginx
#查看仓库里的镜像
[root@centos7_golang ~]# curl -X GET http://192.168.12.40:5000/v2/_catalog -k
{"repositories":["nginx"]}
[root@centos7_golang ~]# curl -X GET http://192.168.12.40:5000/v2/nginx/tags/list -k
{"name":"nginx","tags":["latest"]}