问题描述
我正在尝试使用express运行一个简单的节点应用程序,但是出现此错误:
I am trying to run a simple node application with express but I get this error:
这是我的工作目录:
我运行以下命令将当前源代码目录安装到节点容器内的 / var / www
并运行节点npm start来启动应用程式;
但我收到上面的错误并且不确定该怎么做:
I ran the following command to mount my current source code directory to /var/www
inside the node container and run node npm start to start up the app;but I get the error above and not sure what to do:
docker run -p 8085:3000 -v /home/joel/workspace/plural_docker_webdev:/var/www node -w "/var/www" node npm start
我得到这个错误:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"-w\": executable file not found in $PATH": unknown.
ERRO[0000] error waiting for container: context canceled
推荐答案
Docker告诉您命令命中错误。
它正在尝试使用命令 -w
运行节点
图像。
因为 -w
不是命令,它会引发此错误。
Docker is telling you that the command hit an error.It is trying to run the node
image with the command -w
.Since -w
is not a command, it throws this error.
这是因为您有将 node
写在您可能不想要的地方。
This is because you have written node
in a place you probably didn't mean to.
您的命令被解释为:
docker run -p [port_info] -v [volume_info] node [command]
您可以这样重写命令,它应该可以正常工作:
You can rewrite your command like so and it should work fine:
docker run -p 8085:3000 -v /home/joel/workspace/plural_docker_webdev:/var/www -w "/var/www" node npm start
这篇关于Docker:来自守护程序的错误响应:OCI运行时创建失败:container_linux.go:296:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!