I would like to populate a entry in config file at run time via docker compose

I have tomcat installed in a container, inside it there is application configuration file. I would like to populate a value inside it during run time. (before that I dont know what the value so cant populate at the time of building the image)

I am invoking service with docker-compose up, and I would like the value in configuration file gets replaced via the value I provide to docker compose as parameter

  • Docker opens up a tiny new window that does nothing
  • How to get IP address of running docker container
  • how to automatically monitor and restart the docker container when it crashes down?
  • “chfn: PAM: System Error” Intermittently in Docker Hub Builds
  • What is image “containersol/minimesos” in minimesos?
  • Using RQ with a Docker container hosted on Heroku
  • something like docker-compose up -e “value at run time via docker compose”

     URL for server
     SERVERADD=https://{{value at run time via docker compose}}/{{index}} 
    

    Can I accomplish this with environment variable or any other way kindly suggest !!!

  • .Net Core Machine Key alternative for webfarm
  • Docker images Ubuntu 14.04 not connected internet
  • Start Solr cloud on Docker Swarm (1.12) without Zookeeper
  • docker lvm thin pool cleanup
  • docker https for local development
  • How to use Docker volumes as persistent volumes for Mesos/Marathon?
  • One Solution collect form web for “I would like to populate a entry in config file at run time via docker compose”

    This is normally done in an ENTRYPOINT or CMD script that is built into the image.

    The script checks for the environment variable, does the replacements or other work required, then continues on to run the command as before.

    #!/bin/sh
    if [ -n "$SOME_ENV" ]; then
      sed -i '' -e 's/^param=.*/param='"$SOME_ENV"'/' /etc/file.conf
    fi
    exec "$@"
    

    The script needs to be added to an image, the Dockerfile could be:

    FROM whatever
    COPY docker-entrypoint.sh /entrypoint.sh
    ENTRYPOINT [ "/entrypoint.sh" ]
    CMD [ "run_server", "-o", "option" ]
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.