Docker私有仓库管理和删除本地仓库中的镜像

2020-06-17 06:39:34易采站长站整理

##localhost:5000表示仓库地址,fdf13fa91c6e表示images id,xxx-centos7.5.1804表示镜像名称,1.0表示版本号。

或:
[root@xxx-pub /]# docker tag docker.io/centos:centos7.5.1804 localhost:5000/xxx-centos7.5.1804:1.0

4、 直接上传:


[root@xxx-pub /]# docker push localhost:5000/xxx-centos7.5.1804:1.0
The push refers to a repository [localhost:5000/xxx-centos7.5.1804]bcc97fbfc9e1: Pushed
1.0: digest: sha256:7c14180942615fef85cb5c8b1388e028be1a8f79694a5fa30a4025173e42ad61 size: 529
[root@xxx-pub /]#

在PUSH的过程中可能报类似如下的错误(以下是网络上的错误提示):


[root@localhost ~]# docker push 192.168.174.128:5000/hello:latest
The push refers to a repository [192.168.174.128:5000/hello]unable to ping registry endpoint https://192.168.174.128:5000/v0/
v2 ping attempt failed with error: Get https://192.168.174.128:5000/v2/: http: server gave HTTP response to HTTPS client
v1 ping attempt failed with error: Get https://192.168.174.128:5000/v1/_ping: http: server gave HTTP response to HTTPS client
[root@localhost ~]#

解决办法:

使用的是https,修改/etc/sysconfig/docker(这里是Centos7下的docker)文件,加上ADD_REGISTRY=’–add-registry 192.168.18.162:5000′,INSECURE_REGISTRY=’–insecure-registry 192.168.18.162:5000′ (上面是历史的docker版本的配置),如下图:

但是在新的docker容器仓库的配置中,自己的docker容器中的配置采用(这里在docker registry和另外pull镜像的机器上都指定如下的配置):

指定完成之后,要重启docker,重启的配置如下:


[root@youx-pub volumes]# systemctl restart docker

另外:查看一下docker.service,查看一下配置文件:


[root@youx-pub registry]find / -name docker.service
/sys/fs/cgroup/memory/system.slice/docker.service
/sys/fs/cgroup/devices/system.slice/docker.service
/sys/fs/cgroup/blkio/system.slice/docker.service
/sys/fs/cgroup/cpu,cpuacct/system.slice/docker.service
/sys/fs/cgroup/pids/system.slice/docker.service
/sys/fs/cgroup/systemd/system.slice/docker.service
/usr/lib/systemd/system/docker.service
[root@youx-pub registry]# vim /usr/lib/systemd/system/docker.service

 

然后执行一下:


#因为可以用于systemctl启动的docker.service文件变化了,所以得执行以下配置。然后执行docker的重启工作
systemctl daemon-reload
systemctl restart docker