What is the use of exec command?

EXEC command is used to run a second command in an already running docker container. When a docker container is started by means of START or RUN commands, we optionally specify a startup command which is the first command that is executed as soon as the container starts up. During scenarios where we would want to run another command on the already running container, we use the EXEC command along with the command to run.


> docker exec -it c669abe2068a bash

In the above example, the EXEC command runs a "bash" command on the running container resulting in opening a bash terminal.

Docker Posted May 17, 2020

Join the Newsletter

Subscribe to get our latest content by email.
    We won't send you spam. Unsubscribe at any time.
    We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept