Containers and state
| Command | What it does |
|---|---|
docker ps |
running containers: status, ports, uptime |
docker ps -a |
all containers, including stopped and exited ones |
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}" |
compact view without long IDs or port lists |
docker restart memos |
restart the process; doesn’t pull a new image or apply Compose edits |
docker stop memos |
stop gracefully: sends SIGTERM, then SIGKILL after 10 s |
docker rm -f memos |
stop and remove the container; leaves volumes untouched |
docker top memos |
processes inside the container as seen from the host |
docker port memos |
which container ports are published on the host |
docker restart doesn’t reread compose.yaml or .env — to apply edits, recreate the container with
docker compose up -d (The compose config hash).
Logs
| Command | What it does |
|---|---|
docker logs memos |
full container output since creation |
docker logs -f --tail 100 memos |
last 100 lines, then follow live |
docker logs --since 15m memos |
lines from the last 15 minutes (1h, 2026-11-21T10:00) |
docker logs -t --tail 50 memos |
prefix each line with a UTC timestamp |
docker logs --details memos |
include extra log driver attributes (labels, env vars) |
docker logs memos 2>&1 | grep -i error |
search across stdout and stderr together |
docker logs reads output from the json-file and local drivers. Without a size limit in /etc/docker/daemon.json,
the log file grows without bound and eventually fills the disk (Docker on Ubuntu).
Shell access and files
| Command | What it does |
|---|---|
docker exec -it memos sh |
open a shell inside the container (bash isn’t in every image) |
docker exec -it -u 0 memos sh |
enter as root when the image runs as a non-root user |
docker exec memos env |
print environment variables inside the container |
docker cp memos:/etc/nginx/nginx.conf ./ |
copy a file to the host; swap the arguments to copy back in |
docker diff memos |
show what the container wrote to its layer (A added, C changed, D deleted) |
docker run --rm -it --network container:memos nicolaka/netshoot |
run curl, dig, and ss inside the network of a minimal container |
scratch and distroless images don’t even ship sh, so docker exec fails with executable file not found.
Debug networking with a sidecar container using --network container:<name>, and pull files out with docker cp.
Container and image details
| Command | What it does |
|---|---|
docker inspect memos |
full JSON: networks, mounts, env vars, state, limits |
docker inspect -f '{{.State.ExitCode}} {{.State.OOMKilled}}' memos |
exit code and whether the OOM killer terminated the process |
docker inspect -f '{{.State.Health.Status}}' memos |
healthcheck status if defined in the image or Compose file |
docker inspect -f '{{json .Mounts}}' memos | jq |
attached volumes and host bind mounts |
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' memos |
container IP addresses across all attached networks |
docker inspect -f '{{.LogPath}}' memos |
path to the container’s log file on the host |
docker image inspect traefik:v3.7 -f '{{.Architecture}} {{index .RepoDigests 0}}' |
image architecture and digest |
The -f (--format) flag takes a Go template; capitalized field names match the keys in full docker inspect output.
Resource load
| Command | What it does |
|---|---|
docker stats |
live CPU, memory, network, and disk usage per container (Ctrl+C to exit) |
docker stats --no-stream |
single snapshot without live refresh — handy for logs or scripts |
docker stats --no-stream memos traefik |
snapshot for specific containers only |
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" |
name, CPU, and memory only |
By default a container has no memory limit, so the LIMIT column shows the host’s total RAM. When a container hits a
configured limit, the kernel kills the process: docker inspect reports OOMKilled: true and ExitCode: 137.
Disk usage and cleanup
| Command | What it does |
|---|---|
docker system df |
disk space used by images, containers, volumes, and build cache |
docker system df -v |
detailed breakdown per image, container, and volume |
docker image prune |
remove untagged (<none>) layers left over from updates and builds |
docker image prune -a |
remove all images with no existing container |
docker image prune -a --filter "until=168h" |
remove unused images older than a week |
docker builder prune |
clear BuildKit build cache (-a clears all cache) |
docker container prune |
remove stopped containers |
docker network prune |
remove user-defined networks with no containers |
docker volume ls -f dangling=true |
list volumes not attached to any container |
Networks and volumes
| Command | What it does |
|---|---|
docker network ls |
list networks on the host |
docker network inspect proxy |
subnet, gateway, and containers on the proxy network (Docker networks) |
docker volume ls |
list all Docker volumes |
docker volume inspect memos_data |
locate the volume on disk (Mountpoint under /var/lib/docker/volumes/) |
Docker Compose
Run these commands from the directory containing compose.yaml (or pass -f /opt/memos/compose.yaml).
| Command | What it does |
|---|---|
docker compose ps |
containers in the current stack (docker compose ls lists all stacks on the host) |
docker compose up -d |
start the stack and recreate services whose definition changed |
docker compose up -d --remove-orphans |
same, plus remove containers for services dropped from the file (Orphan containers in Compose) |
docker compose pull && docker compose up -d |
pull fresh images and recreate updated services |
docker compose logs -f --tail 50 |
follow live logs for every service in the stack |
docker compose exec db mariadb -u root -p |
run a command inside a service by its compose.yaml name |
docker compose config |
print the resolved config after .env substitution and overrides |
docker compose down |
stop and remove the stack’s containers and networks; volumes stay |
docker compose down -v also deletes the stack’s named volumes — databases and uploaded files included. Skip -v
during a routine restart or recreate.