docker 安装 docker-registry

docker search registry

下面的镜像会默认拉取。且拉取 lastest 版本的

mkdir registry

cd registry

vi docker-compose.yml

version: "3.8"
services:
  registry:
    image: registry
    container_name: registry
    restart: always
    ports:
      - "5000:5000"
    volumes:
      - "/home/docker/registry:/var/lib/registry"
    networks:
      - vm_net
networks:
   vm_net:
     external: true

mkdir registry-web

version: "3.8"
services:
  registry_web:
    image: hyper/docker-registry-web  
    container_name: registry_web
    restart: always
    ports:
      - "5001:8080"
    environment:
      - REGISTRY_URL=http://192.168.50.101:5000/v2
      - REGISTRY_NAME=192.168.50.101:5000
      - REGISTRY_READONLY=false
    volumes:
      # ?
      - "/home/docker/registry:/var/lib/registry"
    networks:
      - vm_net
networks:
  vm_net:
    external: true

创建网络
docker network create vm_net

检测 docker-compose.yml 格式

docker-compose config -q

启动
docker-compose.yml 目录下执行
docker-compose up -d

docker ps 查看启动的容器
docker logs id 查看日志

访问 web(需要提前关闭防火墙或开放端口)

192.168.50.101:5001

将刚才的两个镜像推送到私服

docker tag registry 192.168.50.101:5000/registry
docker tag hyper/docker-registry-web 192.168.50.101:5000/hyper/docker-registry-web

docker images 查看可看见有四个镜像了

sudo vi /etc/docker/daemon.json
{
    "insecure-registries": ["192.168.50.101:5000"]
}

sudo systemctl restart docker
posted @ 2023-08-08 21:45  YangDanMua  阅读(41)  评论(0编辑  收藏  举报