简体   繁体   中英

starting container process caused “exec: \”command\“: executable file not found in $PATH”: unknown

Attempting to run command fails from docker exec, but not from an interactive shell.

Shell

# command which echo
/usr/bin/echo
# which echo
/usr/bin/echo
#

docker exec

C:\dev> docker ps -n 1
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
93eb09dcde3b        ubuntu              "/bin/bash"         4 minutes ago       Up 4 minutes                            peaceful_knuth
C:\dev> docker exec peaceful_knuth command which echo
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"command\": executable file not found in $PATH": unknown
C:\dev> docker exec peaceful_knuth which echo
/usr/bin/echo
C:\dev>
$ type command
command is a shell builtin

command is a shell builtin. There is no /usr/bin/command . To run a shell builtin, first run the shell.

docker ...... sh -c 'command which echo'

I figured it out not seven seconds after posting. Today's lesson: RTFM.

From https://docs.docker.com/engine/reference/commandline/exec/ docker exec -ti my_container sh -c "echo a && echo b"

The result

C:\dev> docker exec peaceful_knuth command which echo
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process 
    caused "exec: \"command\": executable file not found in $PATH": unknown
C:\dev> docker exec peaceful_knuth which echo
/usr/bin/echo
C:\dev> docker exec peaceful_knuth sh -c "command which echo"
/usr/bin/echo
C:\dev>

From https://stackoverflow.com/users/9072753/kamilcuk , upvote his answer.

C:\dev> docker exec peaceful_knuth type command
OCI runtime exec failed: exec failed: container_linux.go:349: starting container 
     process caused "exec: \"type\": executable file not found in $PATH": unknown
C:\dev> docker exec peaceful_knuth sh -c "type command"
command is a shell builtin
C:\dev>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM