Docker build with custom Dockerfile name
( 21 Articles)
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 whose file structure looks like this:
. ├── Dockerfile ├── Dockerfile.dev ├── docker-compose.yml ├── index.js └── package.json
When using the Dockerfile.dev, I run:
docker build -f Dockerfile.dev .
When using the typical Dockerfile, I run:
docker build .
- Docker: How to Retag an Image
- Start, Pause, Restart, Stop, and Delete a Docker Container
- How to Install Docker Compose on Ubuntu 21.04 and 21.10
- How to Check Docker Desktop and Docker Engine Versions
- Docker: How to List Running and Stopped Containers
You can also check out our Docker topic page for the latest tutorials, examples, tips, and tricks.
View all comments