Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-exec failed: "cd": executable file not found in $PATH

Tags:

docker

cd

exec

I used this command:
docker exec compassionate_mclean cd /root/python
The error returned is

docker-exec: failed to exec: exec: "cd": executable file not found in $PATH

Kindly help me out

like image 656
sabarish Avatar asked Jan 20 '15 04:01

sabarish


2 Answers

cd is a built-in shell command, you can't set it as the command to run. You have to use:

docker exec -i compassionate_mclean bash -c "cd /root/python && python myscript.py"

If you want to see the output make sure to add the -i flag as shown above. In this case however, you can simply run python as your entrypoint:

docker exec -i compassionate_mclean python /root/python/myscript.py
like image 66
Abdullah Jibaly Avatar answered Sep 22 '22 23:09

Abdullah Jibaly


You can't do that, you can do either docker exec -it my_container /bin/bash and then issue several commands with this interactive sessions, or docker exec -d my_container touch myfile if you just want to create a file, see the examples at https://docs.docker.com/reference/commandline/cli/#examples_3

like image 4
user2915097 Avatar answered Sep 21 '22 23:09

user2915097