Let’s Encrypt certificates and docker

I'm running a WordPress site via docker-compose (LEMP-stack) configured with a Let's Encrypt certificate. It works really good!

I'm also running Zoneminder in another container. It's self-sustained (image includes Apache/MySQL), and has no connection to the WordPress-site.

WordPress is accessed by https://<myurl> and Zoneminder is accessed via https://<myurl>:<portnumber>/zm.

My question is: How can I make the SSL-certificate work for both sites? Can they share a folder (use volumes that both point to the same host-directory), or should I copy certificates between the containers? Or is it more to certificates than just those files?

Any guidance would be very much appreciated! I'm sharing my complete yaml-config files below for both wordpress and zoneminder.

WordPress, docker-compose.yml

version: '3' services: db: image: mysql:8.0 container_name: db restart: unless-stopped env_file: .env environment: - MYSQL_DATABASE=wordpress volumes: - dbdata:/var/lib/mysql command: '--default-authentication-plugin=mysql_native_password' networks: - app-network wordpress: depends_on: - db image: wordpress:5.4.1-fpm-alpine container_name: wordpress restart: unless-stopped env_file: .env environment: - WORDPRESS_DB_HOST=db:3306 - WORDPRESS_DB_USER=$MYSQL_USER - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD - WORDPRESS_DB_NAME=wp volumes: - wordpress:/var/www/html - /home/user/docker-data/wordpress/shared_with_container:/var/www/html/shared_with_host networks: - app-network webserver: depends_on: - wordpress image: nginx:1.15.12-alpine container_name: webserver restart: unless-stopped ports: - "80:80" - "443:443" volumes: - wordpress:/var/www/html - ./nginx-conf:/etc/nginx/conf.d - certbot-etc:/etc/letsencrypt networks: - app-network certbot: depends_on: - webserver image: certbot/certbot container_name: certbot volumes: - certbot-etc:/etc/letsencrypt - wordpress:/var/www/html command: certonly --webroot --webroot-path=/var/www/html --email <email> --agree-tos --no-eff-email <url> -d <url> volumes: certbot-etc: wordpress: dbdata: networks: app-network: driver: bridge 

Zoneminder, docker-compose.yml

version: '3' services: zm: container_name: zoneminder image: dlandon/zoneminder restart: unless-stopped privileged: true ports: - '<portnumber>:443' - '<another_portnumber>:9000' environment: - TZ=Europe/Stockholm - SHMEM=50% - PUID=1000 - PGID=1000 - INSTALL_HOOK=0 - INSTALL_FACE=0 - INSTALL_TINY_YOLO=0 - INSTALL_YOLO=0 - MULTI_PORT_START=0 - MULTI_PORT_END=0 volumes: - /home/user/docker-data/zm:/config:rw - /home/user/docker-data/zm/data:/var/cache/zoneminder:rw networks: - app-network networks: app-network: driver: bridge 

submitted by /u/jslettengren
[link] [comments]
Source: Reddit