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