Chapter 6 · 6.4
Updating containers, cleaning up and limiting logs
Updating
A container doesn't update itself. You fetch the new images and restart the containers:
anna@web1:~$ cd /srv/diensten
anna@web1:/srv/diensten$ sudo docker compose pull
anna@web1:/srv/diensten$ sudo docker compose up -d
Only the containers with a new image are recreated. Your data is stored in volumes and is kept.
- Before a major update, read the app's release notes. Sometimes you need to change something first.
- Before an update, make a backup of the volumes (see Backing up databases and Docker volumes properly), or at least a snapshot.
- A fixed version in the tag, such as
vaultwarden/server:1.37.5, prevents surprises. You then raise it yourself. Withlatestyou get the latest version with everypull.
Cleaning up
Old images stay on your disk. Check how much space Docker uses and clean up:
anna@web1:~$ sudo docker system df
anna@web1:~$ sudo docker image prune
docker image prune only removes unnamed images that no longer belong to anything. With -a it removes all images that no container uses.
Please note: Be careful with docker volume prune and docker system prune --volumes. They can delete data you still need.
Limiting logs
Docker stores the output of each container in a log file that grows without limit by default. Set a limit in /etc/docker/daemon.json:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
anna@web1:~$ sudo systemctl restart docker
anna@web1:~$ cd /srv/diensten && sudo docker compose up -d --force-recreate
The limit only applies to containers created afterwards, which is why you recreate them.
Stopping and removing
| Command | What does it do? |
|---|---|
sudo docker compose stop | Stops containers, deletes nothing |
sudo docker compose down | Removes containers and network; volumes are kept |
sudo docker compose down -v | Also removes the volumes: all your data is gone |
