user9121114
user9121114

Reputation:

How to set environment variables for a java project running through docker?

I have a java project that is running using maven through a docker container. I have a properties file that specifies local environment variables. However, I want modify the environment variables in java or possibly through maven pom.xml or docker file/docker compose.

I tried setting my environment variables in docker file using

ENV new_env = old_env 

format but when I ran docker:run, it didn't work. This is what I got.

bc6cc4> Execute a program under the supervision of a valid init process (tini)
bc6cc4> 
bc6cc4> Command line options:
bc6cc4> 
bc6cc4>   --version: Show version and exit.
bc6cc4>   -h: Show this help message and exit.
bc6cc4>   -s: Register as a process subreaper (requires Linux >= 3.4).
bc6cc4>   -v: Generate more verbose output. Repeat up to 3 times.
bc6cc4>   -g: Send signals to the child's process group.
bc6cc4>   -l: Show license and exit.
bc6cc4> 
bc6cc4> Environment variables:
bc6cc4> 
bc6cc4>   TINI_SUBREAPER: Register as a process subreaper (requires Linux >= 3.4)
bc6cc4>   TINI_VERBOSITY: Set the verbosity level (default: 1)
bc6cc4> 

After these errors my project just stopped and I had to manually quit out. Any suggestions?

Upvotes: 2

Views: 1790

Answers (1)

fmatar
fmatar

Reputation: 3470

If you want to run with docker use the -e flag

More information from the docs:

https://docs.docker.com/engine/reference/run/#env-environment-variables

Upvotes: 2

Related Questions