在Docker中构建流星应用程序时,“你已经以root身份运行Meteor”

时间:2016-10-26 03:51:15

标签: meteor build root

我使用

在dockerfile中构建了一个Meteor应用程序图像
RUN ["meteor", "build", "--directory", "/meteor_app"]

并遇到以下错误:

Step 11 : RUN meteor build --directory /meteor_app
---> Running in 2be64a8e21df
You are attempting to run Meteor as the "root" user. If you are developing,
this is almost certainly *not* what you want to do and will likely result in
incorrect file permissions. However, if you are running this in a build process
(CI, etc.) or you are absolutely sure you know what you are doing, add the
`--unsafe-perm` flag to this command to proceed.
The command 'meteor build --directory /meteor_app' returned a non-zero code: 1
{"exitCode":8, "message":"docker build failed or timeout "}

添加--unsafe--perm标志后:

RUN ["meteor", "--unsafe-perm", "build", "--directory", "/meteor_app"]

错误仍然存​​在:

Step 11 : RUN meteor --unsafe-perm build --directory /meteor_app
---> Running in c0e79de335c7
You have run Meteor as root. Your permissions in your app directory will be
incorrect if you ever attempt to perform any Meteor tasks as your non-root
user. You probably didn't want this, but you can fix it by running the
following from the root of your project:
sudo chown -Rh <username> .meteor/local
'/meteor_app' is not a Meteor command. See 'meteor --help'.
The command 'meteor --unsafe-perm build --directory /meteor_app' returned a non-zero code: 1
{"exitCode":8, "message":"docker build failed or timeout "}

如何解决?

在Meteor 1.4.2之后发生此错误,但我没有找到任何文档。

谢谢!

2 个答案:

答案 0 :(得分:3)

显然是一个自动流星更新,出于安全原因禁止根构建......

解决了以root用户身份从meteor的app根目录运行以下命令:

export METEOR_NO_RELEASE_CHECK=true
curl https://install.meteor.com/?release=1.4.1.3 | sh

注意:您可以指定您选择的流星版本。

More info about this issue

答案 1 :(得分:2)

您可以通过在容器中创建用户,使用USER命令切换到该用户并从那里运行meteor来解决此问题。这比以root身份运行所有内容更好。