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 ?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.