sbt-native-packager icon indicating copy to clipboard operation
sbt-native-packager copied to clipboard

dockerBuildInit doesn't work

Open TimWSpence opened this issue 2 years ago • 2 comments

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 😅

TimWSpence avatar May 06 '22 20:05 TimWSpence

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?

muuki88 avatar May 08 '22 11:05 muuki88

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!

TimWSpence avatar May 08 '22 14:05 TimWSpence

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)

Goffen avatar Dec 12 '22 08:12 Goffen

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

JMdoubleU avatar Mar 07 '23 01:03 JMdoubleU

You can append it via docker build options

muuki88 avatar Mar 07 '23 17:03 muuki88

@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)

JMdoubleU avatar Mar 07 '23 23:03 JMdoubleU

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

touchdown avatar May 07 '23 02:05 touchdown