“You have run Meteor as root” when building meteor

2019-02-27 12:42发布

问题:

I built a Meteor app image in a dockerfile with

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

and met the following error:

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 "}

After the --unsafe--perm flag added:

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

the error still exists:

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 "}

How to fix it?

This error occurs after Meteor 1.4.2, but I didn't find any docs for it.

Thanks!

回答1:

You can fix this problem by creating a user in your container, switching to it with the USER command and running meteor from there. It's also a better practice than just running everything as root.



回答2:

Apparently is an automatic meteor update that forbid root build for security reasons...

Solved running the following commands from meteor´s app root directory as root user:

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

NOTE: You can specify the meteor release of your choice.

More info about this issue