title: Mail server docker with certbot
body: <p>I pull <a href="https://github.com/tomav/docker-mailserver" rel="nofollow noreferrer">https://github.com/tomav/docker-mailserver</a> for setup a mail server. 
  I would like add Let's encrypt support, so I pull too <a href="https://hub.docker.com/r/certbot/certbot/~/dockerfile/" rel="nofollow noreferrer">https://hub.docker.com/r/certbot/certbot/~/dockerfile/</a></p>
  
  <p>I do a Docker compose file with this 2 container :</p>
  
  <pre><code>version: '2'
  services:
   nginx:
  image: pixelfordinner/nginx
  container_name: pixelcloud-nginx_proxy-nginx
  restart: always
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - "./volumes/conf.d:/etc/nginx/conf.d:ro"
    - "./volumes/vhost.d:/etc/nginx/vhost.d:ro"
    - "./volumes/certs:/etc/nginx/certs:ro"
    - "/usr/share/nginx/html"
  nginx-proxy:
   image: jwilder/docker-gen
   container_name: nginx-proxy
   depends_on:
    - nginx
   volumes_from:
    - nginx
   volumes:
    - "/var/run/docker.sock:/tmp/docker.sock:ro"
    - "./data/templates:/etc/docker-gen/templates:ro"
    - "./volumes/conf.d:/etc/nginx/conf.d:rw"
  entrypoint: /usr/local/bin/docker-gen -notify-sighup pixelcloud-nginx_proxy-nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
  
  letsencrypt-nginx-proxy:
  restart: always
  image: jrcs/letsencrypt-nginx-proxy-companion
  container_name: ssl
  depends_on:
    - nginx
    - nginx-proxy
  volumes_from:
    - nginx
  volumes:
    - "/var/run/docker.sock:/var/run/docker.sock:ro"
    - "./volumes/vhost.d:/etc/nginx/vhost.d:rw"
    - "./volumes/certs:/etc/nginx/certs:rw"
  environment:
    - "NGINX_DOCKER_GEN_CONTAINER=nginx-proxy"
   mail:
  image: tvial/docker-mailserver:2.1
  hostname: mail
  domainname: example.com
  container_name: mail
  ports:
  - "25:25"
  - "143:143"
  - "587:587"
  - "993:993"
  volumes:
  - maildata:/var/mail
  - mailstate:/var/mail-state
  - ./config/:/tmp/docker-mailserver/
  - "$PWD/etc/:/etc/letsencrypt/"
  - "$PWD/log/:/var/log/letsencrypt/"
  environment:
  - ENABLE_SPAMASSASSIN=1
  - ENABLE_CLAMAV=1
  - ENABLE_FAIL2BAN=1
  - ENABLE_POSTGREY=1
  - ONE_DIR=1
  - DMS_DEBUG=0
  - SSL_TYPE=letsencrypt
  cap_add:
  - NET_ADMIN
  certbot:
  image: certbot/certbot
  container_name: certbot
  command: certbot certonly --standalone -d mail.example.com
  ports:
  - "8083:80"
  - "4432:443"
  volumes:
    - /etc/letsencrypt:/etc/letsencrypt
    - /var/lib/letsencrypt:/var/lib/letsencrypt
  </code></pre>
  
  <p>But certbot does not create any certificate. 
  There is a conflict between nginx and certbot containers with the 443 port. </p>
  
  <p>If I use the 443 port for certbot, my domain is not reachable and so the certbot domain verification fail. 
  If I use 443 for nginx, certbot is not working. 
  I don't know what to do... </p>