Docker Community Forums

Share and learn in the Docker community.

Docker engine api exec - executable file not found in $PATH

docker

(Bunjee) #1

Hi,

I am trying to create a dir inside a running docker container and I want to do it remotely using the docker engine api.
I am using Postman to test the communication so first I create the exec instance like this:

http://unix:/var/run/docker.sock:/containers/97bfae66b11f/exec

with body:

{“Cmd”:[“mkdir testDir”],
“Tty”:true,
“AttachStdout”:true
}

and then I use the returned Id to start the exec like this:

http://unix:/var/run/docker.sock:/exec/32360df5a0a7a9b8790664171584495175f056342079377fd4993b296246b7c8/start

but I get an error:

�OCI runtime exec failed: exec failed: container_linux.go:296: starting container process caused "exec: \"mkdir testDir\": executable file not found in $PATH": unknown

Any ideas how to execute the command from http request?


(Bunjee) #2

Ok, found it.
mkdir is under /bin so the Body request should be “/bin/mkdir/” and the folder name separately inside the array:

{"Cmd":["/bin/mkdir","testDir"],
"Tty":true,
"AttachStdout":true

}
and it works fine.

EDIT: It also works without putting “/bin/”