Search code examples
dockerdockerfilenaming-conventions

How to name Dockerfiles


I'm unsure of how to name Dockerfiles. Many on GitHub use Dockerfile without a file extension. Do I give them a name and extension; if so what? Or do I just call them Dockerfile?


Solution

  • [Please read the full answer]Don't change the name of the dockerfile if you want to use the autobuilder at hub.docker.com. Don't use an extension for docker files, leave it null. File name should just be: (no extension at all)

    Dockerfile
    

    However, now you can name dockerfiles like,

    test1.Dockerfile
    $ docker build -f dockerfiles/test1.Dockerfile  -t test1_app .
    

    or

    Dockerfile.test1
    $ docker build -f dockerfiles/Dockerfile.test1  -t test1_app .
    

    This will also work.

    If you handle multiple files that live in the same context, you could use STDIN:

    test1.Dockerfile
    $ docker build -t test1_app - < test1.Dockerfile