在哪里可以配置Docker容器的启动用户UID? [英] Where can I configure the start user UID for Docker containers?

查看:876
本文介绍了在哪里可以配置Docker容器的启动用户UID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以配置Docker容器的起始用户UID?默认情况下,它使用UID 999与系统上的其他用户冲突。

Where can I configure the start user UID for Docker containers? By default it uses UID 999 which conflicts with some other users on my system.

推荐答案

在Dockerfile中,运行以下命令:

In your Dockerfile, run the following command:

RUN groupadd -r -g 1234 newusername && useradd -r -u 1234 -g newusername newusername
USER newusername

这将创建一个用户 newusername with GID 1234 and UID 1234,then run the container with a default user newusername

This will create a user newusername with GID 1234 and UID 1234, then run the container with a default user newusername.

这篇关于在哪里可以配置Docker容器的启动用户UID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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