Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How can I run a docker exec command inside a docker container

When I try to run the following command I get an error :

docker exec -i nullmailer sendmail -f user@yahoo.com

This shows the following error:

the docker command does not exist
by

3 Answers

espadacoder11
you can run any command in a running container just knowing its ID (or name):

docker exec -it <container_id_or_name> echo "I'm inside the container!"

Note:The container needs to be running.
sandhya6gczb
Use docker ps to get the name of the existing container.
Use the command docker exec -it <container name> /bin/bash to get a bash shell in the container.
Or directly use docker exec -it <container name> <command> to execute whatever command you specify in the container.
pankajshivnani123
You need to get inside the container and then try to execute your command

Follow these steps:

1. Use docker ps to get the name of the existing container
2. Use the command docker exec -it <container name> /bin/bash to get a bash shell in the container
3. Or directly use docker exec -it <container name> <command> to execute whatever command you specify in the container.

Login / Signup to Answer the Question.