Docker Containers
24%
Running Commands in Containers
Sometimes, after starting a container, you may want to run additional commands inside it. These commands are usually useful for debugging, exploration and administration tasks (like migrating databases). In this case, a useful command is docker exec.
To better understand how docker exec works, let's first create and start a container:
docker run -d --name my_ubuntu_container ubuntu sleep infinity
At this point, we have a running Ubuntu container that is executing the sleep infinity command to keep it alive. Now we can use docker exec to run additional commands:
# List files in the root directory of the container
docker execPainless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Unlock now  $31.99$25.59Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
