Dockerfile: unable to find user xxx : no matching entries in passwd file解决方案

编程入门 行业动态 更新时间:2024-10-10 10:25:45

Dockerfile: unable to find user xxx : no matching entries in passwd file<a href=https://www.elefans.com/category/jswz/34/1770581.html style=解决方案"/>

Dockerfile: unable to find user xxx : no matching entries in passwd file解决方案

报错信息

在制作Docker镜像的过程中,完成软件安装等操作后,一般会切换为普通用户启动相应的服务,就需要用到USER指令。但有时候这个指令会报错:

docker: Error response from daemon: unable to find user : no matching entries in passwd file.

解决方案

如果遇到这个问题,可以在使用USER指令之前,先创建用户。

RUN useradd -s /bin/bash your_user_name

网上有很多其他的方案,其中一个是使用USER ID代替用户名,的确可以成功,但是进入容器后,会是普通用户权限,很多操作都执行不了,如果容器是用来开发和调试的,就不太方便了。

相关知识

Docker官方文档中关于USER指令的说明。

USER <user>[:<group>]

或者

USER <UID>[:<GID>]

The USER instruction sets the user name (or UID) and optionally the user group (or GID) to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.

“USER”指令设置运行映像时要使用的用户名(或UID)和可选的用户组(或GID),“Dockerfile”中紧随其后的任何“RUN”、“CMD”和“ENTRYPOINT”指令都将用该用户执行。

请注意,当为用户指定组时,用户将只有指定的组成员资格。任何其他配置的组成员身份都将被忽略。

需要注意

当用户没有指定组时,镜像(或下一条指令)将在root组运行。

在容器中创建Windows用户的方法

在Windows上,如果用户不是内置帐户,则必须首先创建该用户。这可以通过在Dockerfile中调用net user命令来完成。

RUN net user /add Patrick

更多推荐

Dockerfile: unable to find user xxx : no matching entries in passwd file解决方案

本文发布于:2024-02-11 14:38:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1681497.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案   find   user   Dockerfile   unable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!