codegurukool.com · Free coding tutorials & online compiler

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

Run this code in the online editor

← Stop, start and remove containersDockerfile →