« Back to home

Docker lifecycle with Caddy

Caddy was recently updated to 0.8.31. My website’s Docker image was built with the previous version, so I had to update the corresponding Dockerfile and rebuild it on the Docker Hub2.

To update the container running on my DigitalOcean droplet, I just ran the following:

docker pull steeef/stp5net
docker stop stp5net
docker rm stp5net
docker run -d --restart unless-stopped <environment-specific-options-here>  --name stp5net steeef/stp5net

Notice I’m using the --restart unless-stopped restart policy3 for the run command. Docker runs as a daemon on my host, and this is a pretty simple way to ensure the container’s normally running. Note that this particular policy was added in Docker 1.9. Previous versions can use always for similar functionality.