docker系列2: 自建docker仓库

2020-12-28  本文已影响0人  Andy_1ee

有些时候为了使用方便,我们需要自己手动搭建自己的docker仓库,搭建docker仓库的方法比较简单
在准备作为docker仓库的机器上安装好docker,将docker换源

# 拉取仓库镜像
docker pull registry
# 运行仓库
docker run -d -v /registry:/var/lib/registry -p 10000:5000 --restart=always --privileged=true --name registry image_id
# 查看自己的docker仓库
docker ps

使用上述方式就可以轻松的搭建出属于自己的docker仓库

docker pull first_image
docker tag first_image dockerhost:10000/first_image
docker push dockerhost:10000/first_image

使用此方式搭建仓库后, 我们在客户端制作好镜像后push时会报错, 这是因为默认docker客户端使用的是https请求, 我们需要将客户端也设置为http请求

# 客户端配置
vim /etc/docker/daemon.json
# 增加以下配置
"insecure-registries":["192.168.1.100:10000"]

重启客户端docker服务

systemctl daemon-reload
systemctl restart docker
上一篇下一篇

猜你喜欢

热点阅读