Docker: Logs & shells
5 Docker commands: Logs & shells. Click a command to see what each part does.
Docker: Logs & shellsIndex
- Whole sheet120
- Basics: images & containers11
- Volumes & networks4
- Find & inspect containers7
- Environment variables & container config12
- Software versions inside containers & images9
- Logs & shells5
- Run containers3
- Images4
- Cleanup6
- Docker Compose v27
- Container lifecycle & live changes10
- Builds, multi-platform & moving images11
- Volumes, networks & remote hosts in depth12
- Compose: more commands9
- Swarm mode10
Logs & shells5
docker logs -f --tail 200 -t <container>Follow the last 200 log lines with timestampsWhat each part does
docker logs <container>the container's stdout/stderr-f--follow: keep streaming new lines--tail 200start from the last 200 lines (alias -n)-t--timestamps: prefix each line with its time
docker logs --since 15m <container> 2>&1 | grep -i errorLogs from the last 15 minutes, errors onlyWhat each part does
--since 15monly lines from the last 15 minutes (also 1h30m or an RFC3339 time)2>&1merge stderr into stdout, so grep also sees error output| grep -i errorkeep lines containing "error", any case
docker exec -it <container> shOpen a shell inside a running containerWhat each part does
docker exec <container>run a command in a running container-i--interactive: keep stdin open-t--tty: allocate a terminalshthe command to run (use bash if the image has it)
docker exec -e <KEY>=<value> -w <dir> <container> <cmd>Run a one-off command with env and workdirWhat each part does
-e <KEY>=<value>set an environment variable for this command only-w <dir>working directory inside the container<cmd>command to run; wrap chains as sh -c "a && b"
docker cp <container>:<path> ./ ; docker cp ./<file> <container>:<path>Copy a file out of / into a containerWhat each part does
docker cp <container>:<path> ./container → current host directory;thendocker cp ./<file> <container>:<path>host → container
Nothing matches.
My DevOps Playbook by Angelo John Calleja