peter Schiza
peter Schiza

Reputation: 387

Environment variables with docker run -e

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 ?

Upvotes: 2

Views: 5228

Answers (1)

SiKing
SiKing

Reputation: 10329

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.

Upvotes: 4

Related Questions