Dev.to
7/14/2026

The original title is "Interactive containers and exec: get inside, run commands, get out"
Original: Interactive containers and exec: get inside, run commands, get out
Short summary
A practical tutorial covering Docker interactive mode (-it) and docker exec for entering and debugging running containers. Explains the difference between docker run -it (new container) and docker exec -it (existing container), detached mode (-d), and the container lifecycle tied to its main process. Includes concrete command examples for inspection, debugging, and one-off package installation.
- •docker run -it creates a new interactive container; docker exec -it enters an already-running one
- •-i keeps stdin open, -t allocates a pseudo-terminal; together they simulate a real shell
- •Anything installed via exec is ephemeral — permanent changes belong in the Dockerfile
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



