- Make sure you have docker already installed.
- Install the Nginx proxy with
docker-gen
sudo docker run --name=Nginx -d \ --restart=always \ -p 80:80 -p 443:443 \ -v /data/certs:/etc/nginx/certs:ro \ -v /var/run/docker.sock:/tmp/docker.sock:ro \ -v /data/Nginx/vhost.d:/etc/nginx/vhost.d \ -v /data/Nginx/html:/usr/share/nginx/html \ --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy \ jwilder/nginx-proxy
- Since I run portainer, start it up with the
VIRTUAL_HOST
andVIRTUAL_PORT
environment variables so that docker-gen can pick it up. You can do this with any app you desire.
sudo docker run --name Portainer -d \ --restart=always \ -p 9000:9000 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data \ -e VIRTUAL_HOST=portainer.local.network \ -e VIRTUAL_PORT=9000 \ portainer/portainer
- Now to use the Let's encrypt container to make certificates for our docker containers:
sudo docker run --name=Letsencrypt -d \ --restart=always \ -v /data/certs:/etc/nginx/certs:rw \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ --volumes-from Nginx \ jrcs/letsencrypt-nginx-proxy-companion
- To enable SSL for your site, set the environment variables
VIRTUAL_PROTO=https
,VIRTUAL_PORT=433
environment as well as theLETSENCRYPT_HOST
andLETSENCRYPT_EMAIL
variables so that docker-gen can pick it up. You can do this with any app you desire. You will also need to mount the certificates and keys within the SSL folder of the container for the container to use the LetsEncrypt keys.
This blog is a knowledge dump of all the technical information floating around in my head. It deals with anything involving software, hardware, gadgets, and technology.
Mar 2, 2018
Automatically make web apps use HTTPS with Let's Encrypt, Nginx, and Docker
Mar 1, 2018
Making Docker Daemon listen on network port during start-up
Took a bit of time to find the relevant documentation piece, so I thought I would outline it here for easy reference.
Option 1:
This should work for some systems, although distributions that use
systemctl
may have their docker.service
entry overwrite this setting, so you will need to use option 2.- If not already created, create the file
/etc/docker/daemon.json
- Add in the following:
{ "hosts": ["fd://", "tcp://0.0.0.0:2375"] }
- Restart docker and check the docker daemon process. It should have the additional -H flag like so:
$ sudo ps aux | grep dockerd root 31239 0.7 0.2 1007880 72816 ? Ssl 15:03 0:00 /usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
Option 2:
- Edit the service by running:
sudo systemctl edit docker.service
- Add the following lines:
[Service] ExecStart= ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
- Reload the service configuration:
sudo systemctl daemon-reload
- Restart the daemon:
sudo systemctl restart docker.service
- Use the last step of the previous option to test whether docker is listening on the network port
Subscribe to:
Posts (Atom)