Back to all blogs3 min read
How to execute shell command on running docker container?
Use the below syntax:
Ankush Jain
Lead Software Engineer (VP) | Software Architect
Published May 3, 2020Updated Nov 24, 2026
Use the below syntax:
docker exec -ti <container_id> <command>To check the container id, run docker container ls command in the console.
Examples:
- To print date in the console -
docker exec -ti date - To echo Hello World in console -
docker exec -ti 011f0b0f68ce echo "hello world" - To create a directory inside container -
docker exec -ti 011f0b0f68ce mkdir -p "/home/databox"
Reference - https://docs.docker.com/engine/reference/commandline/exec/