docker exec -it my-container bash
Meaning: Executes a command inside a running container.
Usage: To run commands in an interactive terminal within a container.
Example: docker exec -it my-container bash
opens a bash shell in the my-container
container.
Explanation of -it
Flag:
i
: Interactive mode, keeps STDIN open.t
: Allocates a pseudo-TTY, allowing interactive terminal features.Example: docker exec -it my-container sh
opens a shell in the my-container
container for interactive use.