docker swarm部署portainer registry

docker swarm部署本地仓库registry与portainer

docker swarm 2个节点

ljh1 192.168.8.88 manager

ljh2 192.168.8.98 worker

创建overlay网络

docker network create -d overlay platform

添加host标签

docker node update ljh1  --label-add host=ljh1
docker node update ljh2  --label-add host=ljh2

docker swarm部署本地仓库

1.数据卷挂载registry数据目录

mkdir -p /usr/local/registry
chmod -R 777 /usr/local/registry

2.创建docker-swarm配置文件

设置对接网络为platform,platform为外部网络

version: '3.6'

services:
  registry:
    image: registry:2.7.1
    ports:
      - "5000:5000"
    volumes:
      - /usr/local/registry:/var/lib/registry
    networks:
      - platform
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.labels.host == ljh2]
        
networks:
  platform:
    external: true

3.部署registry

docker stack deploy -c docker-registry.yml registry

4.验证

http://192.168.8.98:5000/v2/_catalog

docker swarm部署portainer

1.数据卷挂载registry数据目录

mkdir -p /usr/local/portainer
chmod -R 777 /usr/local/portainer

2.创建docker-swarm配置文件

version: "3.6"
services:
  portainer:
    image: portainer/portainer
    ports:
      - "9000:9000"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/usr/local/portainer:/data"
    networks:
      - platform
    deploy:
      replicas: 1
      placement:
        constraints: [node.role == manager]

networks:
  platform:
    external: true

3.部署portainer

docker stack deploy -c docker_portainer.yml portainer

4.验证

http://ljh1:9000

你可能感兴趣的:(docker)