Introduction
Sometimes you need to run a command inside a running container to check its status or fix something. The docker exec command lets you do that by opening a terminal inside the container or running a quick command.
When you want to check the logs or files inside a running container without stopping it
When you need to run a quick fix or update inside a container, like installing a package
When you want to open an interactive shell inside a container to explore or debug
When you want to run a command inside a container to check its environment or settings
When you want to test a command inside a container before adding it to the Dockerfile