You may name your Dockerfiles however you like. The default filename is Dockerfile (without an extension), and using the default can make various tasks easier while working with containers. In the example provided, each Dockerfile builds from a different, architecture-specific, upstream image.
Specify a Dockerfile (-f)$ curl example.com/remote/Dockerfile | docker build -f - . The above command will use the current directory as the build context and read a Dockerfile from stdin. $ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug .
Notice there is a dot .
at the end of both commands.
docker build -f MyDockerfile .
Or with a tag:
docker build -t mysuperimage -f MyDockerfile .
This Works
docker build doronaviguy/helloworld -f SomeDockerFile .
Docker build Documentation
The last parameter to docker build is the build path, when you put .
it means this is the path where you will find the Dockerfile
. When you change it to Dockerfile.app
it will then try and look for Dockerfile.app/Dockerfile
, which isn't correct.
I'm not sure if it will still work, but you used to be able to do this.
$ docker build -t deepak/app - < Dockerfile.app
Try that and see if it helps, if not, maybe open a docker issue to add this feature back in, or update the documentation on how to use a Dockerfile with a different name.
More info here: http://docs.docker.io/en/latest/commandline/command/build/
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 .
This should work,
docker build -t <tag-name> -f <file-name> .
You can acheive this also using docker-compose.
In your docker-compose.yml under the build section, you can specify the directory in which you store your dockerfile and its alternate-name as follow :
build:
context: "/path/to/docker/directory"
dockerfile: "dockerfile-alternate-name"
docker-compose
Windows User should try below command:
docker build -f absolute_docker_file_path dot
for example :
docker build -f D:\Code\core-api\API_TEST.Dockerfile .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With