Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Start with simple stack to get Portainer running with Caddy #75

Closed
regbo opened this issue Apr 22, 2021 · 2 comments
Closed

Comments

@regbo
Copy link

regbo commented Apr 22, 2021

First of all, thank you. These guides made getting docker swarm up and running a total breeze (coming from rancher 1.6)

After just going through them, I would suggest starting the guide with a simple "soup to nuts" section that brings portainer online, with caddy proxying requests, without the need for configuring Traefik first. While not as powerful as Traefik, caddy can be more straightforward for swarm noobs. I also think that starting with portainer w/o Traefik will help more people because it allows instant access to a web-ui.

For example, this is what I am using to get fresh managers up and running on portainer:

docker network create --driver=overlay --attachable agent-network
docker network create --driver=overlay --attachable caddy-public

nano manager.yml

version: '3.3'

services:
  agent:
    image: portainer/agent:latest
    environment:
      AGENT_CLUSTER_ADDR: tasks.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-ce:latest
    command: -H tcp://tasks.agent:9001 --tlsskipverify
    volumes:
      - portainer-data:/data
    networks:
      - agent-network
      - caddy-public
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == manager
          - node.labels.portainer.portainer-data == true
      labels:
        - caddy=${DOMAIN?Variable not set}
        - caddy.reverse_proxy={{upstreams 9000}}


  caddy:
    image: lucaslorentz/caddy-docker-proxy:ci-alpine
    ports:
      # Listen on port 80, default for HTTP, necessary to redirect to HTTPS
      - target: 80
        published: 80
        mode: host
      # Listen on port 443, default for HTTPS
      - target: 443
        published: 443
        mode: host
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == manager
    networks:
      - caddy-public
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - caddy_data:/data

networks:
  # added with: docker network create --driver=overlay --attachable agent-network
  agent-network:
    external: true
  # added with: docker network create --driver=overlay --attachable caddy-public
  caddy-public:
    external: true

volumes:
  portainer-data:
  caddy_data:

Next

export DOMAIN=portainer.example.com
docker stack deploy -c manager.yml manager

Finally, navigate to https://portainer.example.com and you are good to go.

I think using the above as a "first step" would greatly simplify the process. Just my 2 cents.

@devzenfr
Copy link

devzenfr commented Sep 7, 2022

Thanks a lot for sharing this! That helped me a lot to setup my VPS. Especially the caddy part, it's way easier to setup than Traefik.

@tiangolo
Copy link
Owner

Thank you! And thanks for the patience.

I I had to deprecate this website and ideas, I would no longer recommend Docker Swarm Mode for new projects: https://dockerswarm.rocks/swarm-or-kubernetes/ 🥲

The website will still be up for historical reasons, but I wouldn't really recommend using Docker Swarm Mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants