Docker build with custom Dockerfile name

Last updated on October 3, 2020 The Plumber Loading... Post a comment

Sometimes you may need two different Dockerfile for just a container, one for the development purpose and the other for the production environment.

To build an image with the Dockerfile that isn’t named Dockerfile, just add the -f flag and the name:

docker build -f [my-custom-dockerfile-name] [path] 

For example, I have a project with the structure like this:

├── Dockerfile
├── docker-compose.yml
├── index.js
└── package.json

When using the, I run:

docker build -f .

When using the typical Dockerfile, I run:

docker build . 
Notify of
Inline Feedbacks
View all comments

Related Articles