我已经按照node.js documentation中的步骤创建了Dockerfile。我试图运行命令docker exec -it mynodeapp /bin/bash
以便进入容器并通过npm安装新软件包,但是出现以下错误
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
有什么想法我在做什么错吗?
作为参考,这就是我的docker-compose和dockerfile的样子
FROM node:latest
RUN mkdir /app
WORKDIR /app
RUN npm install -g nodemon
COPY package.json package.json
RUN npm install
COPY . .
EXPOSE 8080
CMD [ "node", "server.js" ]
和
version: '3'
services:
nodejs:
container_name: mynodeapp
build: .
command: nodemon --inspect server.js
ports:
- '5000:8080'
volumes:
- '.:/app'
networks:
- appnet
networks:
appnet:
driver: 'bridge'
答案 0 :(得分:0)
将docker exec mynodeapp -it /bin/bash
更改为docker exec -it mynodeapp /bin/sh
根据docker documentation,正确的语法如下:
docker exec [OPTIONS]容器命令[ARG ...]
-i
和-t
是选项另一个问题是容器内没有bash
shell,因此您可以使用sh
shell。