docker exec and docker logs
Select an icon to see what it is.
Step 6 of 6
logs -f keeps the stream open
docker logs -f adds follow=1. dockerd sends the existing lines, then keeps the connection open and sends each new line as it is written to the log file. The command ends when you press Ctrl-C or the container stops.
$ docker logs -f web PrevNext
GET /v1.45/containers/e5f6a7b8c9d0e1f2e5f6a7b8c9d0e1f2e5f6a7b8c9d0e1f2e5f6a7b8c9d0e1f2/logs?follow=1&stdout=1&stderr=1
follow=1stdout=1stderr=1
Try it yourself
Run a command inside nginx, then read its logs.
$ docker run -d --name web -p 8080:80 nginx$ docker exec web ls /usr/share/nginx/html$ docker logs web$ curl http://localhost:8080$ docker logs -f web$ docker exec -it web sh$ docker rm -f web