Docker 搭建私有仓库 Registry

Docker DevOps About 1,153 words

说明

私有仓库也是一个镜像,叫做Registry

Harbor是在此基础上增强的功能。https://github.com/goharbor/harbor

拉取镜像

https://hub.docker.com/_/registry

docker pull registry:2.7.1

启动容器

docker run -id --name=c_registry -p 5000:5000 registry:2.7.1

访问

http://localhost:5000/v2/_catalog

返回:

{"repositories":[]}

修改 daemon.json

vim /etc/docker/daemon.json

添加:IP:5000localhost也行,但只能本机访问)

{
  "insecure-registries": ["192.168.0.1:5000"]
}

如果配置过镜像源就追加即可

{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"],
  "insecure-registries": ["localhost:5000"]
}

重启 Docker 服务

sudo service docker restart

启动 registry 镜像

docker start registry:2.7.1

tag

docker tag redis:6.2.6 localhost:5000/redis:6.2.6

查看镜像

# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
redis                  6.2.6               7614ae9453d1        6 days ago          113MB
localhost:5000/redis   6.2.6               7614ae9453d1        6 days ago          113MB

上传镜像到私有仓库

docker push localhost:5000/redis

查看仓库:http://localhost:5000/v2/_catalog

{"repositories":["redis"]}

从私有仓库拉取镜像

docker pull localhost:5000/redis:6.2.6

备注

私有仓库需以IP:PORT/REPOSITORY:TAG为镜像名,否则会推送到公有仓库。

Views: 1,714 · Posted: 2022-02-18

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh