无法启动容器进程:在$PATH中找不到可执行文件“npm run start”。

huangapple go评论78阅读模式
英文:

Unable to start container process: exec: "npm run start" executable file not found in $PATH unknown

问题

我有一个已经容器化的应用程序。
这是它的Docker文件:

FROM front-end-base:latest
COPY ... /app/...
...
EXPOSE 5000
RUN cd /app
CMD ["npm run start"]

front-end-base镜像中已经安装了Node、NPM、Yarn和一些其他包。
Docker文件将应用程序的文件复制过来,使用yarn从yarn.lock安装它们,暴露端口,然后使用npm启动应用程序。

然而,我遇到了以下错误:

“无法运行镜像。错误调用远程方法'docker-run-container' - 无法为容器创建任务: 无法创建shim任务: OCI运行时创建失败: 无法启动容器进程 exec: "npm run start": 在$PATH中找不到可执行文件 unknown

我的最终目标是在Docker开发环境中使其工作。但是,我从命令行、图形界面运行镜像以及创建开发环境进程中都遇到了上述错误。

但是,如果我取最终的镜像,而不是尝试运行应用程序,而是通过以下方式进入容器:

docker run -it fe-test:latest /bin/bash -l

容器成功启动,我能够导航到/app目录,并且能够成功执行"npm run start",没有错误。

我在网上找到了一些其他人提出的与此问题相关的问题,但答案要么对我无效,要么与我的情况无关。

对于任何帮助,我都会非常感激。

英文:

I have an application that I have containerized.
This is its Dockefile:

FROM front-end-base:latest
COPY ... /app/...
...
EXPOSE 5000
RUN cd /app
CMD ["npm run start"]

The front-end-base has Node, NPM, Yarn and a few other packages installed.
The dockerfile copies the app's files over, uses yarn to install them from a yarn.lock, exposes the port, and then uses npm to start the application.

However, I get the following error:

"Failed to run image. Error invoking remote method 'docker-run-container' - fail to create task for container: fail to create shim task: OCI runtime create failed: unable to start container process exec: "npm run start": executable file not found in $PATH unknown

My ultimate goal is to get this working in a Docker Dev environment. However, I get the above error from command line, GUI running the image, and from the create Dev Environment process.

However, if I take the final image and instead of trying to run the app just bash into it via

docker run -it fe-test:latest /bin/bash -l

The container starts successfully, and I am able to navigate to the /app directory and executable "npm run start" successfully with no errors.

I have found several other people online asking semi-related questions but the answers have either not worked for me or not been relevant to my situation.

Any help would be appreicated.

答案1

得分: 1

I realized the problem shortly after posting.

由于我是通过brew安装npm/node/yarn的方式安装,所以这些应用程序并不位于/usr/bin/npm,而是位于brew下的home目录。

这就是为什么它在路径上抱怨,要么直接引用完整路径(如npm),要么创建系统链接都可以解决问题。

英文:

I realized the problem shortly after posting.

Due to the way I installed npm/node/yarn (via a brew installation) to applications were not located at /usr/bin/npm but at a home directory under brew.

This is why it was complaining they were not on the path, either directly referencing the full path (which npm), or creating a system link will fix the problem.

huangapple
  • 本文由 发表于 2023年6月13日 08:12:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76460973.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定