Linux centos中搭建 Docker私有仓库

x33g5p2x  于2022-05-16 转载在 Linux  
字(0.9k)|赞(0)|评价(0)|浏览(304)

搭建docker镜像,并将开发的数据打包成镜像,推送到docker的私有仓库,方便开发。

搭建的步骤如下:

1、拉取registry镜像

docker pull registry

2、生成registry容器,开放5000端口

docker create -it registry /bin/bash
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
docker ps -a
docker exec -it f1c57ca66d28 /bin/sh

3、客户端设置daemon.json文件 (指定私有仓库位置)

vim /etc/docker/daemon.json

101.37.171.235:5000 为自己机器的外网IP和端口号
“https://docker.mirrors.ustc.edu.cn”, “https://hub-mirror.c.163.com” 为可用的外网docker镜像

{"insecure-registries":["101.37.171.235:5000"],
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn", "https://hub-mirror.c.163.com"]
}

4、创建本地的镜像标签

docker pull httpd
docker tag httpd:latest 101.37.171.235:5000/httpd

5、上传镜像并测试

docker push 101.37.171.235:5000/httpd
curl -XGET http://101.37.171.235:5000/v2/_catalog

6、下载镜像测试

docker pull 101.37.171.235:5000/httpd

自此搭建成功

附注、设置docker的registry 开启自启动

docker update --restart=always 1778d51b6342

相关文章