Skip to main content
edited tags
Link
030
  • 13.3k
  • 16
  • 75
  • 175
Source Link

docker-compose local variable declare and use

In the programming language we can define and declare a variable and use it later in the program, can we do same in docker-compose file?
###For example in Java: int x = 100; System.out.println("Number is: "+ x);
Similarly, in docker-compose file, can we declare a local variables and use it later.

###docker-compose file

In the docker-compose file we want to declare tomcat_home as a variable and use it later as shown in example.

values: - tomcat_home: "/usr/local/tomcat" #### # Creating Tomcat Server 1 Server1: image: tomcat hostname: TomcatServer1 container_name: TomcatServer1 volumes: - ${PWD}/tomcat-users.xml:${tomcat_home}/conf/tomcat-users.xml - ${PWD}/server.xml:${tomcat_home}/conf/server.xml