部署Docker私有仓库

部署私有仓库,这里使用nginx作为push的镜像。
下载registry和nginx
docker pull registry
docker pull nginx

[root@localhost data]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
nginx                       latest              602e111c06b6        2 weeks ago         127MB
registry                    latest              708bc6af7e5e        3 months ago        25.8MB

运行,并映射端口和目录
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
将nginx打上自己的标签,注意修改ip
docker tag 602e111c06b6 192.168.36.160:5000/nginx
使用docker push 推上去,报错
docker push 192.168.36.160:5000/nginx

[root@localhost data]# docker push 192.168.36.160:5000/nginx
The push refers to repository [192.168.36.160:5000/nginx]
Get https://192.168.36.160:5000/v2/: http: server gave HTTP response to HTTPS client

解决:

echo '{ "insecure-registries":["192.168.36.160:5000"] }' > /etc/docker/daemon.json

重启docker后再次push

[root@localhost data]# systemctl restart docker
[root@localhost data]# docker push 192.168.36.160:5000/nginx
The push refers to repository [192.168.36.160:5000/nginx]
Get http://192.168.36.160:5000/v2/: dial tcp 192.168.36.160:5000: connect: connection refused

由于重启docker,容器停止了(千万要仔细)

[root@localhost data]# docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                           PORTS               NAMES
e7f7f48cf0b8        registry            "/entrypoint.sh /etc…"   57 minutes ago      Exited (2) 2 minutes ago                             inspiring_hugle

重新启动registry,然后push

[root@localhost data]# docker start e7f7f48cf0b8
e7f7f48cf0b8
[root@localhost data]# docker push 192.168.36.160:5000/nginx
The push refers to repository [192.168.36.160:5000/nginx]
b3003aac411c: Pushed 
216cf33c0a28: Pushed 
c2adabaecedb: Pushed 
latest: digest: sha256:cccef6d6bdea671c394956e24b0d0c44cd82dbe83f543a47fdc790fadea48422 size: 948

通过访问http://192.168.36.160:5000/v2/_catalog,可以检验registry的状态。(记得换成自己的ip)
部署Docker私有仓库_第1张图片

你可能感兴趣的:(Docker,docker)