问题:
docker run learn/tutorial ping www.baidu.com
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"ping\": executable file not found in $PATH": unknown.
ERRO[0000] error waiting for container: context canceled
解决方法:
docker run learn/tutorial /bin/sh -C && ping www.baidu.com
原因:
When you use the exec format for a command (e.g. CMD ["grunt"]
, a JSON array with double quotes) it will be executed without a shell. This means that most environment variables will not be present.
If you specify your command as a regular string (e.g. CMD grunt
) then the string after CMD
will be executed with /bin/sh -c
.
参考:
https://stackoverflow.com/questions/27158840/docker-executable-file-not-found-in-path