Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adduser not found on amazoncorretto:11 #1427

Open
jmcnulty-mosaic opened this issue Jun 30, 2021 · 6 comments
Open

adduser not found on amazoncorretto:11 #1427

jmcnulty-mosaic opened this issue Jun 30, 2021 · 6 comments
Labels

Comments

@jmcnulty-mosaic
Copy link

jmcnulty-mosaic commented Jun 30, 2021

Expected behaviour

Latest version of sbt-native-packager resolves this issue: #1262
However I am still seeing this with the latest version of sbt-native-packager 1.7.6 when I sbt docker:publishLocal
This happened after I updated my base image to amazoncorretto:11. This was the only change in the project.

Actual behaviour

sbt docker:publish fails

Information

, my project/plugins.sbt:
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.6")

The native packager settings that I added to my project:
dockerBaseImage := "amazoncorretto:11"

My build error:

[info] Step 15/23 : RUN id -u demiourgos728 1>/dev/null 2>&1 \|\| (( getent group 0 1>/dev/null 2>&1 \|\| ( type groupadd 1>/dev/null 2>&1 && groupadd -g 0 root \|\| addgroup -g 0 -S root )) && ( type useradd 1>/dev/null 2>&1 && useradd --system --create-home --uid 1001 --gid 0 demiourgos728 \|\| adduser -S -u 1001 -G root demiourgos728 ))
--
854 | [info]  ---> Running in 63d521ba1e5f
855 | [info] /bin/sh: adduser: command not found
  • What sbt-native-packager are you using: 1.7.6
  • What sbt version: 1.5.2
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian ): Mac)S
  • What package are you building (e.g. docker, rpm, ...): docker
  • What version has your build tool (find out with e.g. rpm --version)
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7): amazoncorretto:11
@muuki88 muuki88 added the docker label Jul 1, 2021
@muuki88
Copy link
Contributor

muuki88 commented Jul 1, 2021

Thanks @jmcnulty-mosaic for the detailed issue 🤗

If you don't need a special user you can deactivate this by adding

Docker / daemonUserUid := None,
Docker / daemonGroupGid := None

If you do require this feature then what's the equivalent call in the amazon corretto docker image?

@jmcnulty-mosaic
Copy link
Author

Thanks muuki88 for the quick response. Looks like my build does need that user so I'll need to figure out the answer to your question. I'm finding contradictory info so far so I've got a ways to go. Amazon Corretto should be Debian and Debian allegedly has adduser. I say "should be" since I haven't connected all the dots yet from the corretto:11 Dockerfile to a debian distribution and the fact that adduser clearly isn't present raises some doubt. I'll update this ticket with what I find once I have verified the details myself.

@solarmosaic-kflorence
Copy link

solarmosaic-kflorence commented Jul 22, 2021

amazoncorretto:11 is based on the Amazon Linux 2 image, which doesn't seem to have adduser by default: amazonlinux/container-images#28

I can work around this with:

    dockerBaseImage := "amazoncorretto:11",
    dockerCommands := {
      val commands = dockerCommands.value
      val index = commands.indexWhere {
        case Cmd("RUN", args @ _*) => args.contains("demiourgos728")
        case _ => false
      }
      commands.patch(index, Seq(ExecCmd("RUN", "yum", "-y", "install", "shadow-utils")), 0)
    },

This will install the required dependencies before the adduser command is used:

[info] * Cmd(FROM,WrappedArray(amazoncorretto:11, as, stage0))
[info] * Cmd(LABEL,WrappedArray(snp-multi-stage="intermediate"))
[info] * Cmd(LABEL,WrappedArray(snp-multi-stage-id="a06a43ee-1963-4956-83f0-39dc0e6145d4"))
[info] * Cmd(WORKDIR,WrappedArray(/opt/docker))
[info] * Cmd(COPY,WrappedArray(opt /opt))
[info] * Cmd(USER,WrappedArray(root))
[info] * ExecCmd(RUN,List(chmod, -R, u=rX,g=rX, /opt/docker))
[info] * ExecCmd(RUN,List(chmod, u+x,g+x, /opt/docker/bin/application))
[info] * DockerStageBreak
[info] * Cmd(FROM,WrappedArray(amazoncorretto:11))
[info] * Cmd(USER,WrappedArray(root))
[info] * ExecCmd(RUN,WrappedArray(yum, -y, install, shadow-utils))
[info] * Cmd(RUN,List(id, -u, demiourgos728, 1>/dev/null, 2>&1, ||, ((, getent, group, 0, 1>/dev/null, 2>&1, ||, (, type, groupadd, 1>/dev/null, 2>&1, &&, groupadd, -g, 0, root, ||, addgroup, -g, 0, -S, root, )), &&, (, type, useradd, 1>/dev/null, 2>&1, &&, useradd, --system, --create-home, --uid, 1001, --gid, 0, demiourgos728, ||, adduser, -S, -u, 1001, -G, root, demiourgos728, ))))
[info] * Cmd(WORKDIR,WrappedArray(/opt/docker))
[info] * Cmd(COPY,WrappedArray(--from=stage0 --chown=demiourgos728:root /opt/docker /opt/docker))
[info] * Cmd(EXPOSE,WrappedArray(9000))
[info] * Cmd(USER,WrappedArray(1001:0))
[info] * ExecCmd(ENTRYPOINT,List(/opt/docker/bin/application))
[info] * ExecCmd(CMD,List())

But it does feel a bit messy.

@solarmosaic-kflorence
Copy link

solarmosaic-kflorence commented Jul 22, 2021

Another workaround is to use amazoncorretto:11-alpine, which includes adduser already.

EDIT: although alpine does not include bash, which is causing other problems.

@solarmosaic-kflorence
Copy link

Another workaround:

    daemonUserUid in Docker := None,
    daemonUser in Docker := "daemon"

@muuki88
Copy link
Contributor

muuki88 commented Jul 27, 2021

Thanks for sharing everything you tried and worked.

Regarding the alpine / bash issue. There's an AshScriptPlugin that overrides the bash scripts and should work with alpine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants