Quick and Dirty Portainer and Portainer Agent with Let’s Encrypt SSL

For those that don’t know Portainer is a great open source web GUI for administrating Docker instances. I’m not going to go into advanced setups, but for the casual Docker user, with one or more Docker servers, here are some docker-compose examples. Portainer. Portainer with SSL, Portainer and Portainer Agent, Portainer and Portainer Agent with SSL. See POST to learn how to install certbot for Let’s Encrypt certificates used in these examples.

In these examples I have created the directory /home/username/docker/portainer and that is the directory that will serve as persistent storage for your containers as well as the location for your docker compose file.

mkdir -p docker/portainer
cd docker/portainer
nano docker-compose.yml
Code language: CSS (css)

Portainer

version: '2' services: portainer: image: portainer/portainer-ce container_name: portainer command: -H unix:///var/run/docker.sock ports: - 9000:9000 volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer:/data restart: always
Code language: PHP (php)

Portainer with SSL

version: '2' services: portainer: image: portainer/portainer-ce container_name: portainer command: -H unix:///var/run/docker.sock ports: - 9000:9000 volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer:/data - /etc/letsencrypt/archive/example.com:/certs:ro command: --ssl --sslcert /certs/cert1.pem --sslkey /certs/privkey1.pem restart: always
Code language: PHP (php)

Portainer and Portainer Agent

version: '2' services: portainer: image: portainer/portainer-ce container_name: portainer command: -H unix:///var/run/docker.sock ports: - 9000:9000 volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer:/data restart: always portainer_agent: image: portainer/agent container_name: agent ports: - 9001:9001 volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer/volumes:/var/lib/docker/volumes restart: always
Code language: PHP (php)

Portainer and Portainer Agent with SSL

version: '2' services: portainer: image: portainer/portainer-ce container_name: portainer command: -H unix:///var/run/docker.sock ports: - 9000:9000 volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer:/data - /etc/letsencrypt/archive/example.com:/certs:ro command: --ssl --sslcert /certs/cert1.pem --sslkey /certs/privkey1.pem restart: always portainer_agent: image: portainer/agent container_name: agent ports: - 9001:9001 volumes: - /var/run/docker.sock:/var/run/docker.sock - ~/docker/portainer/volumes:/var/lib/docker/volumes restart: always
Code language: PHP (php)

Leave a comment

Your email address will not be published. Required fields are marked *