Reputation: 39
The docker file that I am using have some variables that I need to modify, but from command line: (this is a part of the docker file)
JAVA_OPTS: "
-Dsomething.something.port = 3333
-Danother.something.port = 2222
Is there a way that I can use to override the port value, but from command line when I use docker-compose up? Thanks.
Upvotes: 0
Views: 223
Reputation: 3463
To do that, you'll need to use a variable in your Dockerfile and then use a build-args
in your docker-compose file.
For example :
# Dockerfile
ARG someport
ARG anotherport
JAVA_OPTS: "
-Dsomething.something.port = $someport
-Danother.something.port = $anotherport
# docker-compose.yaml
build:
context: .
args:
someport: 3333
anotherport: 2222
During the build, the port value set in your compose file will be used.
You can find more about the use of variable (with an example) in the official doc.
Upvotes: 1