Pass parameter (like“TestNode”) in docker run from Ansible or Fig

I need to use dockerized Elasticsearch from dockerhub official image and launch docker container using Fig or Ansible. Both have options for passing standard docker run command params like ports, volume etc, but I could not find a way to pass params like"TestNode" to configure the Elasticsearch cluster name etc.

I cannot modify Dockerfile to alter config as these are runtime config and differ among installation, hence need to pass at runtime.

  • how to split string to array and loop over it?
  • ansible playbook: setup and connect to docker (authentication or permission failure)
  • SaltStack Caches installing package files and reproduce installation later
  • Ansible how to push local image to private registry
  • Edit configuration file for running Docker instance of Kong
  • docker build inside official jenkins container
  • Do anyone have any idea how to use Fig or Ansible to pass such params.

  • Docker Kubernetes cluster error Request had insufficient authentication scopes on Google Cloud
  • inotifywait with Docker command and variable
  • Docker 's Error: libselinux conflicts with fakesystemd
  • docker-compose run --rm doesn't exit container after command is run
  • cURL to DropBox using Symfony 3
  • npm install error with docker - kurento application
  • 2 Solutions collect form web for “Pass parameter (like“TestNode”) in docker run from Ansible or Fig”

    Fig has been replaced by docker compose for quite some time now.

    And the way to pass such parameter is:

    • using runtime environment variables which will be visible by the container run after docker compose up,
    • having a starting script in CMD which will expect and use those environment variables in order to build the right command starting ElsticSearch (with -Dxxx=yyy)

    As -D is specific to Java (JAVA_OPTS) and not as ENV or docker params, this can be passed with JAVA_OPTS environment variable. Like:

    sudo docker run -e JAVA_OPTS=-Des.script.groovy.sandbox.enabled=true -p 9200:9200 elasticsearch:1.7.1

    Now Fig or Ansible can pass ENV variable JAVA_OPTS. Only catch is to ensure original JAVA_OPTS is preserved.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.