Inspecting containers
Logs
Containers running in the background almost always have applications that output some information to logs. This output is captured by Docker by default. This information can be viewed with the docker logs
command.
docker logs <containerIdOrName>
It is also possible to keep the log open. Any new additions to the log will be appended in real time to the terminal. This can be achieved with the -f
or --follow
attribute in the command.
docker logs <containerIdOrName> --follow
Docker exec
Even when a container is running in the background, it is possible to execute commands inside that container. A popular command is bash
. This effectively launches a shell process and enables you to view and interact with the container. You could compare this with an SSH session into the container.
docker exec -it <containerIdOrName> bash
Last updated