Docker搭建镜像仓库和配置缓冲地点

Docker搭建镜像仓库和配置缓冲地点

Docker搭建镜像仓库和配置缓冲地点

参考网址:https://docs.docker.com/engine/reference/commandline/dockerd/#options

一、配置Docker镜像仓库

1、新建docker-compose.yml,内容如下:

version: '3'services:
  docker_registry:
    image: registry:2.7
    ports:
      - 0.0.0.0:22000:5000
    volumes:
      - /mnt/disk/docker/registry:/var/lib/registry
    deploy:
      placement:
        constraints:
          - node.hostname==host-192-168-1-22
      restart_policy:
        condition: on-failure

2、创建DockerSwarm集群

    docker swarm init --advertise-addr 192.168.1.22

3、部署镜像仓库

    docker stack deploy -c docker-compose.yml docker-registery

4、查看运行情况

    docker stack ps docker-registery

5、停止服务

    docker stack rm docker-registery

二、配置Docker镜像存储地点,和配置局域网内的不安全镜像仓库:

1、创建配置

sudo mkdir /mnt/disk/docker/dataroot
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "insecure-registries": ["192.168.0.22:22000"],
  "data-root":"/mnt/disk/docker/dataroot"
}
EOF

2、重新加载配置

sudo systemctl daemon-reload
sudo systemctl restart docker

3、查看是否已修改

sudo docker info | grep Root

Docker搭建镜像仓库和配置缓冲地点
https://www.dearcloud.cn/2019/04/08/20200310-cnblogs-old-posts/20190408-Docker搭建镜像仓库和配置缓冲地点/
作者
宋兴柱
发布于
2019年4月8日
许可协议