Home › Docker Tutorial › Logs and exec
Logs and exec
See output and run commands inside.
docker logs shows what a container printed (-f follows it live, --tail N shows the last N lines). docker exec runs a command inside a running container; with -it you get an interactive shell, for example docker exec -it web sh.
Example code
docker exec web nginx -v
docker logs --tail 1 web