Docker Cheat Sheet/Execute command in running container

Run a command in a running container.

Section: Containers

Execute command in running container

bash
bash
docker exec -it web sh
Explanation

A standard way to inspect or debug a live container.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Containers
Show container logs
Print logs from a container.
OpenIn sheetbashsame section
Follow container logs
Follow container logs from the last 100 lines.
OpenIn sheetbashsame section
Run a container
Create and start a new container.
OpenIn sheetbashsame section
Run detached
Run a container in the background.
OpenIn sheetbashsame section
Run interactively
Run an interactive shell inside a new container.
OpenIn sheetbashsame section
Publish a port
Publish a container port to the host.
OpenIn sheetbashsame section