2

Here is my Dockerfile :

FROM ubuntu:16.04

RUN apt-get update

RUN apt-get install -y default-jdk

ADD sample-docker-1.0-SNAPSHOT.jar app.jar

EXPOSE 8080

ENV SITENAME="ASDASD"

ENTRYPOINT ["java", "-jar", "app.jar"]  

and here is a bit of Java code that i use:

@Value("${SITENAME:testsite}")
private String siteName;

with this setup everything works good and environment value of SITENAME is indeed "ASDASD". But when i try to set that variable with:

docker run -P -d --name spring spring-app -e SITENAME='DOCKERlocal'

it doesn't work (value is the one from Dockerfile). What am i missing here ?

peter Schiza
  • 387
  • 7
  • 23

1 Answers1

4

You want to pass the -e to the docker command. So:

docker run -P -d --name spring -e "SITENAME=DOCKERlocal" spring-app

As you are doing it, you are passing it to the image entrypoint.

SiKing
  • 10,003
  • 10
  • 39
  • 90