如何以非root用户身份运行docker image? [英] How to run docker image as a non-root user?

查看:351
本文介绍了如何以非root用户身份运行docker image?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是码头工人的新人。当我使用命令运行docker图像ubuntu映像时,

  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 

注意: -u 参数相当于 USER 说明。


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屋!

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