sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 439 forks source link

dockerBuildInit doesn't work #1505

Closed TimWSpence closed 1 year ago

TimWSpence commented 2 years ago

Expected behaviour

dockerBuildInit := true should build an image with tini as the entrypoint when I run docker:publishLocal

Actual behaviour

It says that --init is not an option for docker build

Information

AFAICT --init is only an argument to docker run and not docker build. I don't believe that Docker will install tini on an image for you, it will only run tini for you and use it to fork the container process. Which is not very helpful for sbt-native-packager 😅

muuki88 commented 2 years ago

Hi @TimWSpence

Thanks for the issue report. I can't recall how this was added, but the contributor who did seems to use it. I'll try to do some archeology and find out what happend back then.

Which docker version are you using?

TimWSpence commented 2 years ago

Many thanks @muuki88! That's very interesting! I've failed to find any reference to docker build supporting this. I'm not entirely sure how Docker would be able to install it on an arbitrary container? tini is statically linked so I guess it might be possible if it can detect the architecture and kernel version doesn't matter?

I'm running the latest Docker desktop (Docker Desktop 4.7.1 (77678)). Do let me know if I can help in any other way!

Goffen commented 1 year ago

https://github.com/krallin/tini

NOTE: If you are using Docker 1.13 or greater, Tini is included in Docker itself. This includes all versions of Docker CE. To enable Tini, just pass the --init flag to docker run.

If you support tini in build there are quite a lot of changes that needs to be made (download the script, chmod, exec)

JMdoubleU commented 1 year ago

@muuki88 why was this closed? As far as I can tell --init has never been an option for docker build.

muuki88 commented 1 year ago

You can append it via docker build options

JMdoubleU commented 1 year ago

@muuki88

[error] unknown flag: --init
[error] See 'docker build --help'.
[error] java.lang.RuntimeException: Nonzero exit value: 125
[error]     at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:691)
touchdown commented 1 year ago

it is docker run --init per comment above but it is being documented and coded as buildOption sooo there was a misunderstanding?