2

I'm new to Dockerfile nomenclature and have noticed a few different examples of dockerfiles in repos throughout my org including the following types:

  • Dockerfile
  • Dockerfile.build
  • .dockerfile

Is there somewhere I can find a detailed explanation for the different use cases and purposes of each?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
sadsquid
  • 87
  • 1
  • 6
  • I don't think its a hard and fast rule to name dockerfile in any way, the build command can be used to build docker image using any file name – Ayushya Aug 18 '17 at 17:17
  • 1
    I'd stick with the default, `Dockerfile`, unless you have a reason to use any other name. – tkausl Aug 18 '17 at 17:31
  • 1
    The Docker docs themselves also recommend putting each `Dockerfile` in its own directory so you can keep the default filename. Examples: https://docs.docker.com/engine/reference/commandline/build/ and https://github.com/docker/labs. In [moby](https://github.com/moby/moby), it looks like they use a different convention of `Dockerfile[.]`. I have also seen `example.dockerfile` in the wild, though this can be confusing because then all of the Dockerfiles in a given project aren't grouped together when listed. – Taylor D. Edmiston Feb 10 '20 at 16:53
  • 1
    Does this answer your question? [How to name Dockerfiles](https://stackoverflow.com/questions/26077543/how-to-name-dockerfiles) – Dherik Dec 16 '22 at 13:37

1 Answers1

1

This is the docker build command, see the official docs for details.

docker build [OPTIONS] PATH | URL | -

The docker build command expects the file name to exactly be Dockerfile. So, in that case, you can simply do

docker build .

In other cases, you have to specify the full name as

docker build -f Dockerfile.build .

So the file name has nothing to do with the container itself. Those different names are for your own convenience.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Sumsuddin Shojib
  • 3,583
  • 3
  • 26
  • 45