Search code examples
dockermount

Docker --mount throws: executable file not found in $PATH"


Running:

docker run 6740371b6542 --mount
docker run 6740371b6542 --mount source=aws,target=/root/.aws/,readonly

both produce the same error:

container_linux.go:265: starting container process caused "exec: \"--mount\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"--mount\": executable file not found in $PATH".

Can someone explain how to mount a file/folder from the host into the docker container? It seems --mount is the current/latest recommended way to do it.


Solution

  • switching the order of the parameters should resolve that problem docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542

    docker run executes a command as its last parameter. the error you received was due to the container not knowing what the --mount command is

    In the future if you want to run a command in a container dont forget to use bash if you want to preserve path variables

    docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542 /bin/bash -c mysql