我创建了一个
Dockerfile
,它创建了一个以 Ubuntu 映像为基础的 React 项目,并且在运行容器时出现此错误
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "npm": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled
这是
Dockerfile
:
FROM ubuntu:latest
WORKDIR /app
RUN apt update &&\
apt-get -y install curl &&\
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash &&\
export NVM_DIR="/root/.nvm" &&\
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&\
nvm install --lts &&\
npm create vite@latest -y . -- --template react-ts &&\
npm install
EXPOSE 5173
ENTRYPOINT [ "npm", "run", "dev" ]
CMD ["--", "--host"]
我尝试将
npm
和 node
可执行文件添加到路径变量,但它似乎不起作用。