Portainer ssl docker-compose

Portainer SSL with Docker Compose

To enable SSL for Portainer using Docker Compose, you need to follow these steps:

  1. Create a directory for storing the SSL certificates. Let’s call it “ssl” in this example.
  2. Generate or obtain the SSL certificate and private key files. You can use tools like Let’s Encrypt or generate self-signed certificates.
  3. Place the SSL certificate and key files in the “ssl” directory.
  4. Create a docker-compose.yml file and define the Portainer service along with SSL configurations. Here’s an example:

version: '3'

services:
  portainer:
    image: portainer/portainer-ce
    ports:
      - 443:443
    volumes:
      - ./ssl:/certs
    command: --ssl --sslcert "/certs/ssl.crt" --sslkey "/certs/ssl.key"
    restart: always
    

In this example, the SSL certificate and key files are mounted as a volume inside the Portainer container. The container’s command is configured to enable SSL using the provided certificate and key paths. Port 443 is exposed on the host to allow HTTPS traffic.

Note that if you are using self-signed certificates, you may need to configure your browser to trust the certificate to avoid SSL warnings.

After defining the Docker Compose file, you can run the following command to start the Portainer service:


docker-compose up -d
    

Leave a comment