私有仓库服务端:12.40
[[email protected]_golang ~]# docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry-dev --name docker-registry registry:2.4
[[email protected]_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操作,此步骤需在客户端配置,然现在这台即是服务器端又是客户端
[[email protected]_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
[[email protected] ~]# 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
[[email protected]_golang ~]# systemctl daemon-reload
[[email protected]_golang ~]# systemctl restart docker
[[email protected]_golang ~]# docker start docker-registry
[[email protected]_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
#上传镜像至仓库
[[email protected]_golang ~]# docker pull nginx
[[email protected]_golang ~]# docker tag nginx 192.168.12.40:5000/nginx
[[email protected]_golang ~]# docker push 192.168.12.40:5000/nginx
#查看仓库里的镜像
[[email protected]_golang ~]# curl -X GET http://192.168.12.40:5000/v2/_catalog -k
{"repositories":["nginx"]}
[[email protected]_golang ~]# curl -X GET http://192.168.12.40:5000/v2/nginx/tags/list -k
{"name":"nginx","tags":["latest"]}