Docker

Various notes on using Docker. Mostly OS-agnostic, but may include OS-specific tips and tricks.

Running

Config tricks

Maintenance Activities

Updating Docker Images

Watchtower

To easily manage docker image updates in a #homelab setting, look into using Watchtower by "containerrr"

Basic startup command

docker run -d \
  --name watchtower \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower

By default, Watchtower will update all running containers on the system. To have it monitor specific images, specify their name on the command line as an argument, no flag needed.

Removing Containers and images

Since a container is the executed version of an image, this creates dependencies. In order to remove an image, you need to stop, remove the container first. Assuming the running container has an id of abcd and an image called image/wxyz, it would be:

  1. docker ps -a to find the container’s id of abcd
  2. docker stop abcd to stop the container
  3. docker rm abcd (alternatively docker container rm abcd) to remove the stopped container
  4. docker rmi image/wxyz (alternatively docker image rm) to remove the image

Cleaning up