我正在尝试在lxc容器启动时使用 super 用户来启动vncserver(我认为成为容器并不重要)。问题是计算机以root用户身份启动。我的监督程序部分如下所示:
[program:vnc]
directory=/
user=ubuntu
environment=HOME="/home/ubuntu",USER="ubuntu"
priority=901
command=/usr/bin/vncserver -fg -geometry 1024x768 :1
但是,尽管/home/ubuntu/.vnc/passwd中已经存在一个密码,但是我发现日志文件显示了它试图创建密码的过程。
想知道我是否缺少什么?用户不是应该在运行命令之前更改用户$ HOME和$ USER吗?
最佳答案
您可以定义运行具有特定用户名(如果有的话)或UID的容器,而镜像/容器中没有任何现有用户。
Docker文档:https://docs.docker.com/engine/reference/run/#user
USER
root (id = 0) is the default user within a container. The image developer can create additional users. Those users are accessible by name. When passing a numeric ID, the user does not have to exist in the container.
The developer can set a default user to run the first process with the Dockerfile USER instruction. When starting a container, the operator can override the USER instruction by passing the -u option.
-u="": Username or UID
Note: if you pass a numeric uid, it must be in the range of 0-2147483647.
关于vnc - 在Linux容器中使用 super 用户启动vncserver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19168058/