Docker --mount 抛出:在 $PATH 中找不到可执行文件"

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

运行:

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

两者都产生相同的错误:

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".

谁能解释一下如何将 file/folder 从主机挂载到 docker 容器中?好像--mount是current/latestrecommended way做的

切换参数的顺序应该可以解决该问题 docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542

docker 运行 执行一个命令作为它的最后一个参数。您收到的错误是由于容器不知道 --mount 命令是什么

将来如果你想 运行 容器中的命令,如果你想保留路径变量,请不要忘记使用 bash

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