serhii.net

In the middle of the desert you can say anything you want

04 Dec 2022

Docker using custom Dockerfile name

To pass a custom dockerfile, add -f custom_filename:

docker build . -f custom.Dockerfile -t tag:latest ....

Dockerfile naming conventions exist: Dockerfile Naming Convention and Organization – mohitgoyal.co, quoting options from there:

myapp.azure.dev.Dockerfile
myapp.gcp.dev.Dockerfile
myapp.aws.dev.Dockerfile
- 
Dockerfile.myapp.azure.dev
Dockerfile.myapp.i386.azure.dev
Dockerfile.myapp.amd.azure.Dev

From that article I learned that Dockerfiles don’t have to be inside build context anymore! Link: Allow Dockerfile from outside build-context by thaJeztah · Pull Request #886 · docker/cli · GitHub

TL;DR from there

$ docker build --no-cache -f $PWD/dockerfiles/Dockerfile $PWD/context
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus