This is a short guide to run all applications on ssl using docker with nginx+letsencrypt, it therefore utilizes jrcs letsencrypt companion.

1. NGINX Proxy

docker run -d -p 80:80 -p 443:443 \  
  --name nginx-proxy \
  -v /data/certs:/etc/nginx/certs:ro \
  -v /etc/nginx/vhost.d \
  -v /usr/share/nginx/html \
  -v /var/run/docker.sock:/tmp/docker.sock:ro \
  --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true \
  jwilder/nginx-proxy

2. Letsencrypt Companion

Make sure the cert path matches the one of step 1

docker run -d \  
  --name letsencrypt-companion \
  -v /data/certs:/etc/nginx/certs:rw \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  --volumes-from nginx-proxy \
  jrcs/letsencrypt-nginx-proxy-companion

3. Example Container

VIRTUAL_PORT= is optional, however you will need it if your docker image EXPOSEs more than one port.

If you omit the LETSENCRYPT_* ENV variables your container will only be accessible over http.

docker run -d \  
  --name some-ghost \
  -e VIRTUAL_HOST=blog.foo.bar \
  -e VIRTUAL_PORT=2368 \
  -e LETSENCRYPT_HOST=blog.foo.bar \
  -e LETSENCRYPT_EMAIL=foo@bar.com \
  -e "NODE_ENV=production" \
  -v /data/ghost/blog:/var/lib/ghost \
  ghost

4. Success

You should now be able to access a blog at blog.foo.bar using https.