Tag: bitbucket pipeline

有没有一种简单的方法在Bitbucket Pipelines Docker容器中更改为非root用户?

Bitbucketpipe道使用Docker容器来执行任务,默认情况下,Docker容器以root身份运行。 这是NPM生命周期脚本的一个问题,因为NPM在运行脚本时试图降级它的权限。 当执行postinstall脚本时, NPM会抛出一个错误 ,它cannot run in wd %s %s (wd=%s) 。 最简单的解决scheme是使用–unsafe-perm标志运行npm install,但我不喜欢这种方法。 Docker写Dockerfiles的最佳实践指出: 如果一项服务可以运行没有权限,使用USER来更改为非root用户。 当configuration一个典型的Docker容器时,我将创build一个新的非root用户,并以该用户身份运行我的npm脚本。 在阅读Pipelines文档后,我找不到Docker的USER命令的任何等价物。 我可能能够使用useradd , chown和su (还没有testing过),但有一个更简单的解决scheme吗? 不幸的是,添加useradd , chown和su到bitbucket-pipelines.yml脚本部分中断pipe道并导致失败的repo:push webhook。 image: node:6.2 pipelines: default: – step: script: – useradd –user-group –create-home –shell /bin/false node – chown -R node: /opt/atlassian/bitbucketci/agent/build – su -s /bin/sh -c "npm install" node – su […]