Zum Inhalt


docker cheatsheet

Cleanup unused images:

docker image prune -f

Remove stopped containers:

docker container prune -f

View logs of a running container:

docker logs -f nginx:latest
docker-compose logs -f nginx_service

View logs of all running services of a docker-compose.yml file:

docker-compose logs -f

Enter an already running container using bash in interactive mode:

docker exec -it nginx:latest /bin/bash

Inspect an image by running a container:

docker run --rm -it nginx:latest /bin/bash

Execute a command inside a container, removing the container afterwards

docker run --rm nginx:latest ls

Inspect a containers environment variables:

docker run --rm nginx:latest env

List docker networks and images:

docker network list
docker image list

List running containers:

docker ps

List all containers, also stopped:

docker ps -a

docker-compose cheatsheet

Show validated docker-compose.yml config:

docker-compose -f docker-compose.yml config


This is especially handy if you use these files in your program tooling e.g. if you automating things

Letztes Update: August 7, 2022
Erstellt: March 9, 2022