Skip to content

Instantly share code, notes, and snippets.

@thinmy
Last active March 1, 2022 18:22
Show Gist options
  • Save thinmy/9a5d22631a69fb1ba6d5840915c9ccd2 to your computer and use it in GitHub Desktop.
Save thinmy/9a5d22631a69fb1ba6d5840915c9ccd2 to your computer and use it in GitHub Desktop.
Start Portainer in docker swarm with nginx-proxy with ssl support using nginx-proxy-acme-companion.
version: '3.2'
services:
agent:
image: portainer/agent:2.10.0
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-ee:2.10.0
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9443:9443"
- "9000:9000"
- "8000:8000"
volumes:
- portainer_data:/data
networks:
- agent_network
- proxy_network
environment:
- VIRTUAL_HOST=portainer.local
- VIRTUAL_PORT=9443
- VIRUTAL_PROTO=https
- LETSENCRYPT_HOST=portainer.local
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
nginx-proxy:
image: jwilder/nginx-proxy
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
ports:
- "80:80"
- "443:443"
networks:
- proxy_network
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
environment:
- DHPARAM_GENERATION=false
nginx-acme-companion:
image: nginxproxy/acme-companion
networks:
- proxy_network
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- acme:/etc/acme.sh
environment:
- DEFAULT_EMAIL=contato@thinmy.me
whoami:
image: jwilder/whoami
networks:
- proxy_network
environment:
- VIRTUAL_HOST=whoami.local
- LETSENCRYPT_HOST=whoami.local
networks:
agent_network:
driver: overlay
attachable: true
proxy_network:
driver: overlay
attachable: true
volumes:
portainer_data:
certs:
vhost:
html:
acme:
@thinmy
Copy link
Author

thinmy commented Mar 1, 2022

Deploy using command from Portainer documentation.

docker stack deploy -c portainer-agent-stack.yml portainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment