Portainer - how to specify SSL in docker-compose.yml?

simbro picture simbro · Oct 15, 2018 · Viewed 12.1k times · Source

I'm trying to deploy an instance of Portainer to a docker swarm. I'm not sure how to set the correct flag to enable SSL.

From the docs:

$ docker run -d -p 443:9000 --name portainer --restart always -v ~/local-certs:/certs -v portainer_data:/data portainer/portainer --ssl --sslcert /certs/portainer.crt --sslkey /certs/portainer.key

https://portainer.readthedocs.io/en/stable/deployment.html

But how do you translate that into a docker compose yml file?

Answer

w31 picture w31 · Mar 28, 2019

Possibly I'm a bit late to the party, but it looks what you have to use Portainer's flags to enable ssl for your Portainer (as said in documentation) and composerize.com lost that part somewhere, so you should add this to your compose:

command:
  --ssl
  --sslcert /certs/portainer.crt
  --sslkey /certs/portainer.key

or for full compose file:

version: 3
services:
    portainer:
        image: portainer/portainer
        container_name: portainer
        restart: always
        ports:
            - '443:9000'
        volumes:
            - '~/local-certs:/certs'
            - 'portainer_data:/data'
        command:
            --ssl
            --sslcert /certs/portainer.crt
            --sslkey /certs/portainer.key