使用 Eclipse Temurin 17-jre 映像在 Docker 中添加用户的问题

问题描述 投票:0回答:1

我在尝试将用户添加到基于 Eclipse Temurin 17-jre 映像的 Docker 容器时遇到问题。我在 Dockerfile 中使用的命令是:

RUN adduser --disabled-login -u 1000 spring-boot

但是,当我构建图像时,出现以下错误:

Could not build image: The command '/bin/sh -c adduser --disabled-login -u 1000 spring-boot' returned a non-zero code: 127

此命令已经工作了很长时间,但问题从今天早上开始出现。我注意到 17-jre 镜像的最新标签是在两个小时前推送的,可能与这个问题有关

在此基础映像中添加用户之前,是否需要安装不同的命令或软件包?任何帮助将不胜感激!

java docker dockerfile eclipse-temurin
1个回答
0
投票
默认情况下,

adduser
命令在 eclipse-temurin:17-jre 中不存在,但
useradd
存在。

根据您的规范,您可以像这样创建 spring-boot 用户

useradd --uid 1000 --no-create-home --shell /usr/sbin/nologin spring-boot
。但请注意用户 ID 1000,因为它不是唯一的并且链接到 ubuntu 用户。

© www.soinside.com 2019 - 2024. All rights reserved.