“您已经以根用户身份运行Meteor”;在Docker中构建流星应用时 [英] "You have run Meteor as root" when building meteor app in docker

查看:264
本文介绍了“您已经以根用户身份运行Meteor”;在Docker中构建流星应用时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在dockerfile中使用以下命令构建了Meteor应用程序映像

I built a Meteor app image in a dockerfile with

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之后出现此错误,但我没有找到任何相关文档。

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

谢谢!

推荐答案

您可以通过以下方法解决此问题:在容器中创建一个用户,使用 USER 命令切换到该用户,然后从那里运行流星。与仅以root用户身份运行所有内容相比,这是一种更好的做法。

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.

这篇关于“您已经以根用户身份运行Meteor”;在Docker中构建流星应用时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆