其他分享
首页 > 其他分享> > docker

docker

作者:互联网

自定义私有仓库流程

1. 下载registry镜像
[root@test ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
c87736221ed0: Pull complete 
1cc8e0bb44df: Pull complete 
54d33bcb37f5: Pull complete 
e8afc091c171: Pull complete 
b4541f6d3db6: Pull complete 
Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
Status: Downloaded newer image for registry:latest
2. 修改配置文件daemon.json,并重启docker服务
默认是没有该文件的,需要自己创建
    vim /etc/docker/daemon.json
    {"insecure-registries":["172.24.40.174:5000"]}
重启服务
    systemctl restart docker
3. 启动私有仓库
[root@test ~]# docker run -d -p 5000:5000 registry    //5000:5000 第一个5000是物理机5000端口,第二个5000是容器的5000端口
236cde0f69f9d17a7a23e7762e369174eb50dd82fb65c21aec9526b930b11b5f
4. 打标记,上传镜像
[root@test ~]# docker tag my_centos:latest 172.24.40.174:5000/my_centos:latest  //打标记
[root@test ~]# docker tag nginx:latest 172.24.40.174:5000/nginx:latest    //打标记
[root@test ~]# docker images   //查看镜像
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
<none>                         <none>              b1d38b0dcce9        15 hours ago        262 MB
172.24.40.174:5000/my_centos   latest              eaf03d7a25fc        15 hours ago        262 MB
my_centos                      latest              eaf03d7a25fc        15 hours ago        262 MB
172.24.40.174:5000/nginx       latest              f7bb5701a33c        7 days ago          126.3 MB
nginx                          latest              f7bb5701a33c        7 days ago          126.3 MB
busybox                        latest              6d5fcfe5ff17        9 days ago          1.22 MB
centos                         latest              0f3e07c0138f        3 months ago        219.5 MB
registry                       latest              f32a97de94e1        10 months ago       25.76 MB
[root@test ~]# docker push 172.24.40.174:5000/my_centos    //上传镜像
The push refers to a repository [172.24.40.174:5000/my_centos]
c41ed9d79ef4: Pushed 
9e607bb861a7: Pushed 
latest: digest: sha256:d5bbeb3f91e6abfdda2e9de886e33807961055fb6024ee7a48c1503560c146f3 size: 741
5. 客户端使用私有镜像源
也是需要配置daemon.json,内容和服务端一样
然后重启docker服务
docker run -it 172.24.40.174:5000/my_centos

小技巧
172.24.40.174:5000/v2/_catalog
//再浏览器上输入这个就可以查看私有仓库有哪些镜像
172.24.40.174:5000/v2/查出来的镜像名/tags/list
//可以查看该镜像下有哪些标签

标签:5000,centos,172.24,docker,40.174,latest
来源: https://www.cnblogs.com/xhwy-1234/p/12152089.html