Maintain Docker#

Get basic information:

docker system info

Reference: Overview of docker compose CLI

Review log files#

Run, replacing CONTAINER:

docker-compose logs -f -t CONTAINER

Open a shell#

Open a Bash shell, for example:

docker-compose run --rm static bash

Open a Python shell, for example:

docker-compose run --rm web python shell

Our Python projects follow a LOG_LEVEL environment variable, which you can set with -e LOG_LEVEL=DEBUG, for example.

Check project usage#

Show containers’ status:

docker-compose ps

Show containers’ processes:

docker-compose top

Check system-wide usage#

Check drive usage:

docker system df

List containers, images, networks and volumes:

docker container ls -a
docker image ls -a
docker network ls
docker volume ls

Inspect a volume, replacing VOLUME:

docker volume inspect VOLUME

List a volume’s data, replacing VOLUME:

ls /var/lib/docker/volumes/VOLUME/_data/*

Prune objects#

List dangling objects:

docker image ls --filter dangling=true
docker volume ls --filter dangling=true

Prune unused objects:

docker system prune

Remove unused images in addition to dangling ones:

docker system prune -a

Reference: Prune unused Docker objects