014 docker stack 編排服務

1 準備yml文件

    version:docker編排任務的版本,參考官方說明,這個不是本身定義的,,,,node

    image:指定鏡像web

    volumes:掛載日誌目錄,若是宿主機上文件夾不存,啓動時會報錯:invalid mount config for type…docker

    ports:映射端口號,注意多個service的端口號不要相同apache

    replicas:鏡像數bash

    placement.constraints:指定工做節點,對應的是:[node.role == manager]curl

    文檔:https://docs.docker-cn.com/compose/compose-file/測試

version: '3'
services:
  test01:
    image: 192.168.20.201:5000/ipweb
    volumes:
      - /home/log:/home/log
    networks:
      - central
    ports: 
      - 8088:8080
    deploy:
      replicas: 3
      placement:
        constraints: [node.role == worker]
        
  test02:
    image: registry.cn-hangzhou.aliyuncs.com/goldleaf/test:ipweb
    volumes:
      - /home/log:/home/log
    networks:
      - central
    ports:
      - 8089:8080
    deploy:
      replicas: 3
      placement:
        constraints: [node.role == worker]

networks:
  central:
    external:
      name: central

2 編排服務

    2-1 啓動url

docker stack deploy -c docker-stack.yml gh

    2-2 查看全部stackspa

docker stack ls

    2-3 查看某一stack中的全部服務日誌

docker stack services gh

3 訪問測試

curl 192.168.20.201:8088
curl 192.168.20.201:8089
相關文章
相關標籤/搜索