$ command-helper

Docker

Containers, images, logs, Docker Compose and disk cleanup.

Requires Google sign-in

Containers

Running containers
docker ps
All containers, including stopped
docker ps -a
Run a container in the background with a published port
docker run -d --name <container> -p 8080:80 <image>
Open a shell inside a container
docker exec -it <container> sh
Stop and remove a container
docker rm -f <container>
Remove exited containers
docker rm $(docker ps -a -q -f status=exited)
Remove created containers
docker rm $(docker ps -a -q -f status=created)
Follow logs
docker logs -f --tail 100 <container>
CPU and memory usage
docker stats
Container IP addressadvanced
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container>

\{{end}} is an escaped Go template — it is copied as {{end}}.

Images

List images
docker images
Build an image
docker build -t <image> .
Build for another platformadvanced
docker buildx build --platform linux/amd64 -t <image> --push .
Copy a file out of a container
docker cp <container>:/path/in/container ./local-path

Docker Compose

Start everything in the background
docker compose up -d
Rebuild and start
docker compose up -d --build
Stop and remove containers
docker compose down
Stop and remove including volumes
docker compose down -v
Service logs
docker compose logs -f <compose_service>
Run a command in a service
docker compose exec <compose_service> sh

Cleanup

How much space Docker uses
docker system df
Remove everything unusedadvanced
docker system prune -a --volumes

Removes all stopped containers, unused images, networks and volumes. Data in volumes will be lost!