docker私有仓库搭建
编辑于 2021-08-14 18:16:24 阅读 1102
这里宿主机ip为:192.168.10.100
修改宿主机hosts
echo '192.168.10.100 registry.cw.net' >> /etc/hosts
配置
docker-compose.yml
# tell docker what version of the docker-compose.yml we're using
version: '3.1'
services:
registry:
image: registry
restart: always
container_name: registry
ports:
- 5000:5000
volumes:
- ./registry:/var/lib/registry
修改docker配置文件
vi /etc/docker/daemon.json
{
"insecure-registries": [
"registry.cw.net:5000"
]
}
启动该容器
docker-compose up -d
测试
准备一个本地镜像
docker pull busybox:latest ⬅️拉取镜像
打标记
docker tag busybox:latest registry.cw.net:5000/busybox
将本地镜像push到本地仓库
docker push registry.cw.net:5000/busybox
从仓库拉取busybox
docker pull registry.cw.net:5000/busybox
删除
docker rmi registry.cw.net:5000/busybox
通过浏览器查看本地镜像列表
http://localhost:5000/v2/ ⬅️空
http://localhost:5000/v2/_catalog ⬅️会看到本地镜像列表
给虚拟机里的docker使用宿主机的仓库
1、修改宿主机hosts
echo '192.168.10.100 registry.cw.net' >> /etc/hosts
2、修改docker配置文件
vi /etc/docker/daemon.json
{
"insecure-registries": [
"registry.cw.net:5000"
]
}
3、重启docker
systemctl restart docker
其他
正式环境建议用harbor