docker私有仓库搭建及containerd使用私有仓库
这里我们要搭建的私有仓库非harbor,而是更轻量的docker-registry。使用的工具是containerd
私有仓库搭建
```Plain Text
创建目录
mkdir -p /opt/docker/registry
拉取镜像
ctr i pull docker.io/library/registry:2.7.1
创建容器
ctr c create --mount type=bind,src=/opt/docker/registry,dst=/var/lib/registry,options=rbind:rw --net-host --privileged docker.io/library/registry:2.7.1 registry
运行
ctr task start -d registry
# containerd使用私有仓库 containerd的配置文件位置`/etc/containerd/config.toml` 编辑配置文件
Plain Text [plugins."io.containerd.grpc.v1.cri".registry] config_path = ""
[plugins."io.containerd.grpc.v1.cri".registry.auths] [plugins."io.containerd.grpc.v1.cri".registry.configs] [plugins."io.containerd.grpc.v1.cri".registry.headers] [plugins."io.containerd.grpc.v1.cri".registry.mirrors] [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] endpoint = ["https://1j2lgv4y.mirror.aliyuncs.com"] [plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"] [plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
# 私有仓库地址 [plugins."io.containerd.grpc.v1.cri".registry.mirrors."172.16.0.16:5000"] endpoint = ["http://172.16.0.16:5000"]
这里我们要在plugins下面添加一段配置,配置中指定仓库的名称和地址即可。 # containerd推送镜像到私有仓库
Plain Text
修改tag
ctr image tag docker.io/mumu/keepalived01:1.0.0 172.16.0.17:5000/keepalived/keepalived01:1.0.0
推送镜像
ctr image push --plain-http 172.16.0.16:5000/keepalived/keepalived01:1.0.0
# 查看docker registry镜像
Plain Text curl -XGET http://127.0.0.1:5000/v2/_catalog ```