目录
配置过程描述
具体的配置
在本文中使用了两台docker服务器,一台用来搭建私有的仓库,一台用来访问数据库文件。
配置过程描述
创建私有仓库
配置文件 /etc/docker/daemon.json
{
"insecure-registries" : ["192.168.1.10:5000"]
}
完成配置以后重启 docker 服务
systemctl restart docker
启动私有仓库服务
docker run -d -p 5000:5000 registry
打标记
docker tag busybox:latest 192.168.1.10:5000/busybox:latest
docker tag myos:latest 192.168.1.10:5000/myos:latest
docker tag myos:python 192.168.1.10:5000/myos:python
docker tag myos:httpd 192.168.1.10:5000/myos:httpd
上传镜像
docker push 192.168.1.10:5000/busybox:latest
docker push 192.168.1.10:5000/myos:latest
docker push 192.168.1.10:5000/myos:python
docker push 192.168.1.10:5000/myos:httpd
客户机使用私有镜像源
配置文件 /etc/docker/daemon.json
{
"insecure-registries" : ["192.168.1.10:5000"]
}
重启服务 systemctl restart docker
启动容器
docker run -it 192.168.1.10:5000/busybox
docker run -it 192.168.1.10:5000/myos
docker run -d 192.168.1.10:5000/myos:httpd
查看私有仓库有什么样的镜像
curl http://192.168.1.10:5000/v2/_catalog
查看私有仓库的镜像有什么样的标签
curl http://192.168.1.10:5000/v2/myos/tags/list
具体的配置
docker1主机
[[email protected] ~]# vim /etc/docker/daemon.json
{
"insecure-registries" : ["192.168.6.153:5000"]
}
[[email protected] ~]# docker run -d -p 5000:5000 registry
[[email protected] ~]# docker tag busybox:latest 192.168.6.153:5000/busybox:latest
[[email protected] ~]# docker push 192.168.6.153:5000/busybox:latest
The push refers to a repository [192.168.6.153:5000/busybox]
f9d9e4e6e2f0: Pushed
latest: digest: sha256:3058e3a1129c64da64d5c7889e6eedb0666262d7ee69b289f2d4379f69362383 size: 527
docker2主机
[[email protected] ~]# vim /etc/docker/daemon.json
{
"insecure-registries" : ["192.168.6.153:5000"]
}
[[email protected] docker]# docker run -it 192.168.6.153:5000/busybox
Unable to find image '192.168.6.153:5000/busybox:latest' locally
latest: Pulling from busybox
Digest: sha256:3058e3a1129c64da64d5c7889e6eedb0666262d7ee69b289f2d4379f69362383
Status: Downloaded newer image for 192.168.6.153:5000/busybox:latest
[[email protected] docker]# curl http://192.168.6.153:5000/v2/_catalog
{"repositories":["busybox","myos"]}
[[email protected] docker]# curl http://192.168.6.153:5000/v2/myos/tags/list
{"name":"myos","tags":["http1"]}