Docker: Execute Commands inside a Running Container

Last updated on November 2, 2021 A Goodman Loading... Post a comment

To access the terminal of a running container, you can use the following command:

docker exec -it <container name> sh

Or:

docker exec -it <container ID> sh

You can also replace sh with bash.

Note: To exit the container without stopping or killing it, you can press Ctrl + P + Q

You can see the names and IDs of your running contains by performing the command below:

docker ps

Example:

Further reading:

You can also check out our Docker topic page for the latest tutorials, examples, tips, and tricks.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You May Also Like