2

I have created a Dockerfile that installs java, and sets it as an environment variable $JAVA_VERSION. Everything seems to pass. At the end of the Dockerfile I execute a .sh file that references to the $JAVA_VERSION. It says it cannot find the environment variable. I then bash in to the running container, and I cannot find the installed java, nor the java environment variable.

Am I doing something wrong?

user1340582
  • 19,151
  • 35
  • 115
  • 171

1 Answers1

2

It depends on how you set this environment variable.

You should use the ENV directive in the dockerfile (otherwise, you need the option -e on docker run)

I then bash in to the running container,

That would be docker exec -it <yourContainer> path/to/bash, and you should find what the Dockerfile has built.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250