Docker build argument

How does one pass arguments into a dockerfile?

Lets say I have the dockerfile:

  • How to move Marathon to docker at AWS?
  • How do i allocate enough ram to run Object.stringify without a memory / RangeError
  • Running Odoo behind nginx with docker
  • How to skip a gradle task under some cases, which introduced by the bmuschko/gradle-docker-plugin?
  • Docker container on another IP and not reachable
  • Request Entity Too Large - NextCloud in Docker
  • FROM    ubuntu:14.04
    MAINTAINER Karl Morrison
    sudo do-something-here myVarHere

    I would want to build the file as so for example:

    docker build basickarl/my-image-example /directory/of/my/dockerfile "my string to be passed to myVarHere here!"

  • How do I filter docker swarm nodes by label?
  • Resized Azure VM based on the Linux Docker+Rethinkdb image and the data was lost, is this to be expected?
  • Requested JSON data encrypted arbitrarily depending on host
  • Customize mongo docker raise an error when I try to create a new user for database
  • Possible to use Docker machine with continuous integration tools?
  • Docker: Installing libraries on centos image
  • 2 Solutions collect form web for “Docker build argument”

    Docker has ARG that you can use here

    FROM    ubuntu:14.04
    MAINTAINER Karl Morrison
    ARG myVarHere
    RUN do-something-here myVarHere

    And then build using --build-arg:

    docker build --build-arg myVarHere=value

    We’ve had a similar requirement and came up with a relatively simple script that does exactly that:

    We create a file called dockerfile_template in which we use variables just like you describe. The script takes that file, performs string substitutions and copies it to dockerfile (no _template) before calling docker build dockerfile.

    Works pretty good. Also very extensible for future requirements.


    Scrap that. Use build-arg (here)

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