0

i have to create a docker container from an docker image. When the container is started using docker run or docker compose up command, i want to pass some arguments to it and those argument values need to be replaced in a property file that will be available inside the container when it is started. I have tried to use entrypoint or CMD commmand, but it doesnt seems to work. Any idea to resolve this problem?

Jugi
  • 1,244
  • 3
  • 23
  • 51

1 Answers1

0

You can copy arguments in a file and then copy that file inside container. This can be achieved adding similar lines in Docker file

FROM jboss/wildfly

COPY Jberet-postgresql-configds.ddl /tmp/

Now, this file will be inside container at /tmp and ready to be used by programs inside container.

Prateek Jain
  • 2,738
  • 4
  • 28
  • 42
  • thanks for the reply. For example, i have a property files already inside the container where i need to replace a IP address. This IP address will be passed during docker run command only. How to handle this? – Jugi Apr 20 '17 at 20:26
  • Not sure, what you are trying to achieve here. Assigning IPs is not the recommended way. You should be using docker networking to connect machines/network. – Prateek Jain Apr 20 '17 at 20:30
  • This is just for a example, actually the arguments container file path, port number and so on – Jugi Apr 20 '17 at 20:32
  • Please share your use-case if possible. Also refer to this http://stackoverflow.com/questions/34254200/how-to-pass-arguments-to-a-dockerfile – Prateek Jain Apr 20 '17 at 20:34
  • i have to create a container for tomcat server. I have a tomcat.conf file, in that i need to map the port number of other services and its dns name and so on. So i have created a shell script to update those values based on the argument provided during docker run command. i was not able to execute that script with the arguments during container start – Jugi Apr 20 '17 at 20:41
  • thanks for your help. The above link passes arguments during docker build. my use case is to pass valued during docker run – Jugi Apr 20 '17 at 20:43
  • I would again say, you are doing it wrong. services are connected to each other mostly using docker-compose.yml file and exposing required ports. In special cases of DNS or PROXY use HTTP_PROXY in .env file. – Prateek Jain Apr 20 '17 at 20:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/142214/discussion-between-jugi-and-techtrainer). – Jugi Apr 20 '17 at 20:56