矛盾在不同的环境中运行的码头工人建造
当地一切都运行流畅完美的:矛盾在不同的环境中运行的码头工人建造
- 的Mac OS 10.11.6
- 多克尔17.03.1-CE-mac12
远程,在CircleCI上它有所不同:
- Ubuntu 14.04
- 多克尔版本1.9.1-circleci-CP-解决方法
- 我使用CircleCI 1.0,我简要地试图用CircleCI 2.0
我Dockerfile看起来非常类似:
FROM pensiero/apache-php
# Mostly Ubuntu 16.04 install with some php and node/npm
# RUN apt-get install a few packages
COPY . /var/www
WORKDIR /var/www
RUN ["npm","install"]
# or RUN npm install
而且那么乱发动和所有幸福的消失:
npm WARN deprecated [email protected]: ..psst! While Bower is maintained, we recommend Yarn and Webpack for *new* front-end projects! Yarn's advantage is security and reliability, and Webpack's is support for both CommonJS and AMD projects. Currently there's no migration path but we hope you'll help us figure out one.
npm WARN deprecated [email protected]: In 6.x, the babel package has been deprecated in favor of babel-cli. Check https://opencollective.com/babel to support the Babel maintainers
# This one is only there from time to time
npm ERR! Cannot read property 'write' of null
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/babel-traverse/node_modules/lodash):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, chown '/var/www/node_modules/.staging/lodash-23934876/camelCase.js'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/base62):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, chown '/var/www/node_modules/.staging/base62-c9d76f67/.travis.yml'
... bunch of similar lines
npm ERR! path /var/www/node_modules/.staging/react-dom-414d50ba
npm ERR! code EINVAL
npm ERR! errno -22
npm ERR! syscall chown
npm ERR! EINVAL: invalid argument, chown '/var/www/node_modules/.staging/react-dom-414d50ba'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-06-13T13_25_03_833Z-debug.log
显示问题的环境的搬运工信息:
Containers: 0
Images: 0
Server Version: 1.9.1-circleci-cp-workaround
Storage Driver: btrfs
Execution Driver: lxc-1.0.9
Logging Driver: json-file
Kernel Version: 3.13.0-119-generic
Operating System: Ubuntu 14.04.4 LTS (containerized)
CPUs: 2
Total Memory: 58.97 GiB
Name: box731
ID: 7CUB:SOW3:C3EG:LNFC:JWZB:O73I:PFPI:4XLM:NXDI:V44F:XEFB:IGTV
Debug mode (server): true
File Descriptors: 12
Goroutines: 17
System Time: 2017-06-13T15:32:31.903542525Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/bin/docker
Docker Root Dir: /var/lib/docker
WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
随机出现的错误导致我发出https://github.com/moby/moby/issues/783,它引用了一个关于应该修复的AUFS的错误。而且似乎我没有使用AUFS ......所以这可能是无关紧要的。
如果我删除产生错误的行,稍后可以使用CircleCI文档中建议的docker exec
修补程序运行npm install
。
sudo lxc-attach -n "$(docker inspect --format "{{.Id}}" test)" -- bash -c "cd /var/www; npm install"
,它工作正常,但我想获得一个构建神器释放...和exerything跑一样,不保留。
在此先感谢。
这听起来像是已经在https://discuss.circleci.com/t/npm-install-error-that-isnt-reproducing-in-a-local-docker-container/13085报告过的相同的东西。可能值得遵循该线程知道何时修复。它可能与CircleCI有关。
(在CircleCI上经历过这个问题)
这是我的解决方案;编辑&任何其他COPY
,RUN
命令之前添加这些行到你的Dockerfile:
...
RUN install -d -o node -g node /myapp
WORKDIR /myapp
USER node
... (COPY, RUN, etc)
我的容器是基于node:8.1.4
图像。从node:6.11.0
升级时触发此问题。如果您使用不同的图像,那么容器中可用的用户可能不同。在这种情况下,你可以创建一个新用户或者找出已经存在的用户,例如ubuntu
或其他。
这里有一些非常有创意的解决方法,但这是一个非常简单的权限问题。没有深入挖掘它,除了我所需要的,但将USER
添加到Dockerfile已经在我的待办事项列表中,因此并非全部都丢失了。看起来像一个大问题,希望这可以为别人节省一些麻烦。
感谢您的支持!我最初没有找到这个线程,因为在docker中发生'npm install',我会说这个问题显然不同。如果我是正确的,环境不耦合。你怎么看? – AsTeR
虽然,CircleCI采用hack-ish方式实现构建Docker。他们可能会在Docker中做一些特殊类型的Docker,以使其在CircleCI 1.0上工作,并使用只读的btrfs文件系统来引入奇怪的问题。 –
我已经切换到CircleCI 2.0 ...并且我不想再听到这个讨厌的错误!谢谢 – AsTeR