title: How to Configure LetsEncrypt-Cerbot in a Standalone Container
body: <p>I'm trying to find simple documentation on running certbot in a docker-container, but all I can find is complicated guides w/ running certbot + webserver etc. The official page is kinda useless... <a href="https://hub.docker.com/r/certbot/certbot/" rel="nofollow noreferrer">https://hub.docker.com/r/certbot/certbot/</a> .I already have webserver separate from my websites and I want to run certbot on it's own as well.</p>
  
  <p>Can anybody give me some guidance on how I could generate certificates for <code>mysite.com</code> with a webroot of <code>/opt/mysite/html</code>.</p>
  
  <p>As I already have services on port 443 and 80 I was thinking of using the "host-network" if needed for certbot, but I don't really understand why it needs access to 443 when my website is served over 443 already.</p>
  
  <p>I have found something like so to generate a certbot container, but I have no idea how to "use it" or tell it to generate a cert for my site.</p>
  
  <p>Eg:</p>
  
  <pre><code>WD=/opt/certbot
  mkdir -p $WD/{mnt,setup,conf,www}
  cd $WD/setup
  cat &lt;&lt; 'EOF' &gt;docker-compose.yaml
  version: '3.7'
  
  services:
    certbot:
      image: certbot/certbot
      volumes:
        - type: bind
          source: /opt/certbot/conf
          target: /etc/letsencrypt
        - type: bind
          source: /opt/certbot/www
          target: /var/www/certbot
      entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h &amp; wait $${!}; done;'"
  EOF
  chmod +x docker-compose.yaml
  </code></pre>
  
  <p>This link has something close to what I need, (obviously somehow I need to give it my domain as an argument!)</p>
  
  <p><a href="https://stackoverflow.com/questions/44020498/letsencrypt-docker-nginx">Letsencrypt + Docker + Nginx</a></p>
  
  <pre><code> docker run -it --rm \
    -v certs:/etc/letsencrypt \
    -v certs-data:/data/letsencrypt \
    deliverous/certbot \
    certonly \
    --webroot --webroot-path=/data/letsencrypt \
    -d api.mydomain.com
  </code></pre>
  
  <p>I like to keep everything pretty "isolated" so I'm looking to just have certbot run in it's own container and configure nginx/webserver to use the certs seperatley and not have certbot either autoconfigure nginx or run in the same stack as a webserver.</p>