Docker搭建私有仓库

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

搭建私有仓库

参考地址搭建私有仓库

安装运行 docker-registry

查看docker存储路径与对应路径下的大小

docker info | grep Dir

查看对应路径下的大小

du -sh /var/lib/docker

image-20230131111838982

如果大小没有问题的话就可以直接安装了

拉取registry镜像并运行

docker run -d \
    -p 5000:5000 \
    -v /yourDataPath:/var/lib/registry \
    registry

使用 docker ps 指令查看容器是否正常运行部署完成

配置非 https 仓库地址

因为 Docker 默认不允许非 HTTPS 方式推送镜像。我们可以通过 Docker 的配置选项来取消这个限制或者查看下一节配置能够通过 HTTPS 访问的私有仓库。

Ubuntu 16.04+, Debian 8+, centos 7配置方法对于使用 systemd 的系统请在 /etc/docker/daemon.json 中写入如下内容如果文件不存在请新建该文件

{
  "registry-mirrors": [
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com"
  ],
  "insecure-registries": [
    "YOUR IPADDR:5000"
  ]
}

更新配置

给dockerd 发送 SIGHUP 信号dockerd 收到信号后会 reload 配置,查看Insecure Registries是否生效

kill -SIGHUP $(pidof dockerd)
docker info

image-20230131114238517

在私有仓库上传、搜索、下载镜像

**创建好私有仓库之后就可以使用 docker tag 来标记一个镜像然后推送它到仓库。例如私有仓库地址为 127.0.0.1:5000。**使用 docker tag 将 hello-world latest这个镜像标记为 127.0.0.1:5000/hello-world:latest。格式为 docker tag IMAGE[:TAG] [REGISTRY_HOST[:REGISTRY_PORT]/]REPOSITORY[:TAG]

docker tag hello-world:latest 127.0.0.1:5000/hello-world:latest

image-20230131112623789

使用 docker push 上传标记的镜像。

docker push 127.0.0.1:5000/hello-world

image-20230131114422632

用curl查看仓库中的镜像

curl 127.0.0.1:5000/v2/_catalog

image-20230131114631068

先删除已有镜像

docker rmi REPOSITORY

再尝试从私有仓库中下载这个镜像

docker pull 127.0.0.1:5000/hello-world

image-20230131115048507

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: Docker