docker入门五:仓库
2021-06-14 本文已影响0人
沿哲
介绍
之前在docker入门一:镜像中关于仓库提过一嘴
仓库-repository,是集中存放镜像的地方,可分为公共仓库和私有仓库
注册服务器-registry,是存放仓库的具体服务器

registry和repository可以视为一个文件夹下的项目
ip/ubuntu
ip是registry的地址
ubuntu是仓库名
私有仓库实践
- 下载并启动官方给出的registry镜像
docker run -d -p 5000:5000 registry:2

- 添加标签
docker tag 已有镜像名 ip:5000/test1

- 如果此时pull ip:5000/test1 这个镜像会报错

3.1 修改/etc/docker/daemon.json中的内容
表示信任这个私有仓库
{
"insecure-registries": [
"ip:5000"
]
}
3.2 修改/etc/hosts
添加如下内容
127.0.0.1 ip:5000
再执行下面
systemctl daemon-reload
systemctl restart docker
3.3 !!记得检查下 registry这个镜像运行起来的容器是否开启
手动开启下
docker start CONTAINER ID

- 检查,输入以下语句能返回私有仓库中的镜像结果
curl http://ip:5000/v2/_catalog