我写了一个节点服务器,我想用docker compose封装它进行开发(稍后我将添加更多服务)。 这是我的docker-compose.yml:
version: '3'
services:
server:
image: node:alpine
volumes:
- ./
working_dir: /.
environment:
NODE_ENV: development
ports:
- 8009:8009
command: npm run dev
运行docker-compose up
时,我得到:
Recreating bed_server_1 ... error
ERROR: for bed_server_1 Cannot start service server: OCI runtime create failed: container_linux.go:348: starting container process caused "open /proc/self/fd: no such file or directory": unknown
ERROR: for server Cannot start service server: OCI runtime create failed: container_linux.go:348: starting container process caused "open /proc/self/fd: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
我正在使用mac。 知道有什么问题吗?
答案 0 :(得分:1)
由于体积大,可能会发生此错误。您应该尝试删除以下几行:
volumes:
- ./
然后尝试将文件夹映射到docker-compose
文件中声明的卷,如下所示:
services:
server:
image: node:alpine
volumes:
- test_volume:./
working_dir: /.
environment:
NODE_ENV: development
ports:
- 8009:8009
command: npm run dev
volumes:
test_volume:
external: true
答案 1 :(得分:1)
应将卷映射到容器内的文件夹。 ./
并未说明文件夹在容器内的映射位置。也就是说,将卷更改为./:/app
,以将./
目录从主机映射到docker内部的/app
目录,并更新working_dir
,如下所示:
volumes:
- ./:/app
working_dir: /app