在 swarm manager
机上 运行
mkdir -p /docker/portainer
cat > /docker/portainer/portainer-agent-stack.yml << EOF
version: '3.2'
services:
agent:
image: portainer/agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9000:9000"
- "8000:8000"
volumes:
- portainer_data:/data
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
networks:
agent_network:
driver: overlay
attachable: true
volumes:
portainer_data:
EOF
docker stack deploy -c /docker/portainer/portainer-agent-stack.yml portainer
Creating network portainer_agent_network
Creating service portainer_agent
Creating service portainer_portainer
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
wgvoilmhr6fp nginx replicated 3/3 nginx:latest *:80->80/tcp
rum8wkq5jabf portainer_agent global 6/6 portainer/agent:latest
v1hywq89fwov portainer_portainer replicated 1/1 portainer/portainer:latest *:8000->8000/tcp, *:9000->9000/tcp
创建完成之后 随便访问 其中一个node:9000 设置 admin 密码即可开始使用 portainer