如何以非root用户身份运行docker image? [英] How to run docker image as a non-root user?
问题描述
sudo docker run -i -t ubuntu:14.04
默认情况下,它以root身份进入容器。
I搜索这个,但是我无法获得任何如何启动一个非root用户的docker图像,因为我完全是这个主题的开始。
它如果有人用一个例子说明如何以非root用户的形式运行码头图像,那将是很棒的。
docker run
命令具有 -u
参数,以允许您指定其他用户。在您的情况下,假设您的Docker图片中有一个名为 foo
的用户,您可以执行以下操作:
sudo docker run -i -t -u foo ubuntu:14.04 / bin / bash
I'm new to docker. When I run a docker images like ubuntu image by using the command,
sudo docker run -i -t ubuntu:14.04
By default, it is entering into the container as root like this.
I searched regarding this, but I couldn't get any of how to start a docker image as a non root user as I'm completely a starter for this topic.
It would be great if someone explains with an example of how to run a docker image as a non root user.
the docker run
command has the -u
parameter to allow you to specify a different user. In your case, and assuming you have a user named foo
in your docker image, you could run:
sudo docker run -i -t -u foo ubuntu:14.04 /bin/bash
NOTE: The -u
parameter is the equivalent of the USER
instruction for Dockerfile.
这篇关于如何以非root用户身份运行docker image?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!