我有这个docker-compose文件:
rest-api:
image: x/rest-api
build:
context: ./rest-api/dockerfiles/
dockerfile: local.Dockerfile
environment:
- BUILD_ENV=local
ports:
- "8001:8001"
volumes:
- ./rest-api:/var/www/rest-api
user: $UID
web:
image: x/web-front
build:
context: ./web-front
dockerfile: dockerfiles/local.Dockerfile
environment:
- BUILD_ENV=local
depends_on:
- rest-api
links:
- rest-api
ports:
- "3001:3001"
- "35729:35729"
volumes:
- ./web-front:/var/www/web-front
- ./web-front/logs/:/root/.npm/
user: $UID
和这两个local.Dockerfile。 REST的API:
FROM node:8-alpine
RUN mkdir -p /var/www/rest-api/
WORKDIR /var/www/rest-api/
EXPOSE 8001
CMD [ "npm", "run", "dev" ]
Web的前端:
FROM node:8-alpine
RUN mkdir -p /var/www/web-front/
WORKDIR /var/www/web-front/
EXPOSE 3001 35729
CMD [ "npm", "run", "local" ]
我基本上从主机安装了我的所有node_modules,然后将卷映射到容器中相应的文件夹,用于rest-api和web-front。然后我从容器中运行package.json中的命令。 我对rest-api没有任何问题。在Web前端思想中,该过程以Segmentation fault(核心转储)和错误代码139
退出CMD [ "npm", "run", "local" ]
运行:
"NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1",
当我直接在我的计算机上运行npm run local
时,我不会解决这个问题。
我已经尝试了npm rebuild
但没有成功
容器上的节点版本与主机上的节点版本相同。
我有这个调试:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'local' ]
2 info using npm@5.0.0
3 info using node@v8.0.0
4 verbose run-script [ 'prelocal', 'local', 'postlocal' ]
5 info lifecycle web-front@0.5.0~prelocal: web-front@0.5.0
6 silly lifecycle web-front@0.5.0~prelocal: no script for prelocal, continuing
7 info lifecycle web-front@0.5.0~local: web-front@0.5.0
8 verbose lifecycle web-front@0.5.0~local: unsafe-perm in lifecycle true
9 verbose lifecycle web-front@0.5.0~local: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/var/www/web-front/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle web-front@0.5.0~local: CWD: /var/www/web-front
11 silly lifecycle web-front@0.5.0~local: Args: [ '-c',
11 silly lifecycle 'NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1' ]
12 silly lifecycle web-front@0.5.0~local: Returned: code: 139 signal: null
13 info lifecycle web-front@0.5.0~local: Failed to exec local script
14 verbose stack Error: web-front@0.5.0 local: `NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1`
14 verbose stack Exit status 139
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
14 verbose stack at emitTwo (events.js:125:13)
14 verbose stack at EventEmitter.emit (events.js:213:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:125:13)
14 verbose stack at ChildProcess.emit (events.js:213:7)
14 verbose stack at maybeClose (internal/child_process.js:887:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid web-front@0.5.0
16 verbose cwd /var/www/web-front
17 verbose Linux 4.4.0-66-generic
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "local"
19 verbose node v8.0.0
20 verbose npm v5.0.0
21 error code ELIFECYCLE
22 error errno 139
23 error web-front@0.5.0 local: `NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1`
23 error Exit status 139
24 error Failed at the web-front@0.5.0 local script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 139, true ]
您是否知道此错误的来源? 提前谢谢。
答案 0 :(得分:0)
这个问题是因为阿尔卑斯山。 Alpine使用musl而不是glibc,这会导致某些库出现问题。使用debian或任何其他使用glibc的发行版。