How to name Dockerfiles

前端 未结 10 1051
谎友^
谎友^ 2020-12-22 22:17

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 ca

10条回答
  •  忘掉有多难
    2020-12-22 22:52

    Do I give them a name and extension; if so what?

    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.

    Depending on your specific requirements you may wish to change the filename. If you're building for multiple architectures, for example, you may wish to add an extension indicating the architecture as the resin.io team has done for the HAProxy container their multi-container ARM example:

    Dockerfile.aarch64
    Dockerfile.amd64
    Dockerfile.armhf
    Dockerfile.armv7hf
    Dockerfile.i386
    Dockerfile.i386-nlp
    Dockerfile.rpi
    

    In the example provided, each Dockerfile builds from a different, architecture-specific, upstream image. The specific Dockerfile to use for the build may be specified using the --file, -f option when building your container using the command line.

提交回复
热议问题