Try dockerfeed. It uses the docker feature to build a context via stdin. I wrote the script to address exactly your problem I was facing myself.
To replace a Dockerfile with a different one you do it like this:
dockerfeed -d Dockerfile.app . | docker build -t deepak/ruby -
And voilà. Dockerfeed is doing the same as docker build
. It packs the source with its Dockerfile but lets you swap out the old Dockerfile with the desired one. No files are created in the process, no source is changed. The generated tar archive is piped into docker, which in turn sends it down to the docker daemon.
Update:
This was a valid answer in the old days when there was no -f
switch available. With docker version 1.5 this option was introduced. Now you can build provide a different Dockerfile like this:
docker build -f other-Dockerfile .
docker build --help
there is a line where you can find what you are looking for: -f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile')-f
option worked e.g.docker build -f ~/iit-term-synthesis/Dockerfile_arm -t brandojazz/iit-term-synthesis:test_arm ~/iit-term-synthesis/