docker exec

docker exec runs an extra command inside a running container, in the same files and the same network. It is how you look around, test a connection or open a shell.

How it works

docker exec api env shows the environment, docker exec -it api sh opens an interactive shell (bash on Debian images). The command runs as the container's user unless -u says otherwise, and ends without touching the main process.

What breaks

It only works on a running container: one that crashes at start is diagnosed with docker logs, or by running its image with another command. Changes made through exec are lost when the container is recreated; fix the image instead.

In a terminal

docker exec api env
docker exec -it api sh
docker run --rm -it orders-api sh

See it break, then fix it

Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.