How to name Dockerfiles

前端 未结 10 980
谎友^
谎友^ 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:50

    I know this is an old question, with quite a few answers, but I was surprised to find that no one was suggesting the naming convention used in the official documentation:

    $ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug .
    $ docker build -f dockerfiles/Dockerfile.prod  -t myapp_prod .
    

    The above commands will build the current build context (as specified by the .) twice, once using a debug version of a Dockerfile and once using a production version.

    In summary, if you have a file called Dockerfile in the root of your build context it will be automatically picked up. If you need more than one Dockerfile for the same build context, the suggested naming convention is:

    Dockerfile.
    

    These dockerfiles could be in the root of your build context or in a subdirectory to keep your root directory more tidy.

提交回复
热议问题