I recently discovered that I don’t need to manually create data-only containers with
docker-compose anymore. A welcome feature, but one that comes with all the usual migration overhead. I rely heavily on nginx-proxy and letsencrypt-nginx-proxy-companion. Getting it all to work in the style of
docker-compose version 3 took a bit of doing.
My previous tried and true approach is getting pretty stale. It is time to up my Docker game…
nginx-proxy proxies multiple site, but for demonstration purposes, I’m only serving up one with
nginx. I like to put all my individual Docker compositions in their own directories:
The following assumes you have some sort of site you want to serve up from the
mysite/ directory. If not, just create a simple Hello, world! HTML page. Copy and paste the following to
It’s awesome that I can create data-only containers in my
docker-compose.yml, but now I’ve got to manually create a network bridge:
Proxied containers also need to know about this network in their own
Copy and paste the code below:
This will serve up files from the current directory (i.e., the same one that contains the new
index.html page, if created).
The site won’t be accessible yet. That comes next.
As before, put the
nginx-proxy Docker compositions in its own directory:
Create a directory in which to store the Let’s Encrypt certificates:
Copy and paste the following to a file called
nginx-proxy to combine forces with
letsencrypt-nginx-proxy-companion, all in one
If all is well, you should be able to access your site at the address configured.