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

Customizing Docker image fails when container environment variables are used #1324

Closed
ioreskovic opened this issue Apr 2, 2020 · 1 comment
Labels

Comments

@ioreskovic
Copy link

I am trying to customize the image:

    dockerCommands ++= Seq(
      ExecCmd("RUN", "cp", "$JAVA_HOME/lib/security/cacerts", "$HOME/kafka.client.truststore.jks")
    )

Expected behaviour

sbt docker:publishLocal builds an image

Actual behaviour

[info] cp: cannot stat '$JAVA_HOME/lib/security/cacerts': No such file or directory
[info] Removing intermediate container 8b958d8ea255
[error] The command 'cp $JAVA_HOME/lib/security/cacerts $HOME/kafka.client.truststore.jks' returned a non-zero code: 1

Information

  • What sbt-native-packager are you using
    1.7.0
  • What sbt version
    1.3.8
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian )
    MaxOS Catalina 10.15.4
  • What package are you building (e.g. docker, rpm, ...)
    docker
  • What version has your build tool (find out with e.g. rpm --version)
    Docker version 19.03.8, build afacb8b
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7):
    Debian
@ppiotrow
Copy link
Contributor

ppiotrow commented Apr 5, 2020

This is not a bug but behaviour of Docker itself. RUN command has two forms, only one is able to interpret variables. See the explanation in this Stackoverflow answer.

Workaround

dockerCommands ++= Seq(
        Cmd("RUN", "echo ${JAVA_HOME}")
),
[info] Step 21/21 : RUN echo ${JAVA_HOME}
[info]  ---> Running in d03391a31013
[info] /docker-java-home/jre
[info] Step 21/21 : RUN ["echo", "${JAVA_HOME}"]
[info]  ---> Running in 9437d5ff2584
[info] ${JAVA_HOME}

@muuki88 muuki88 added the docker label Apr 6, 2020
@muuki88 muuki88 closed this as completed Apr 6, 2020
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