I have a directory that contains multiple Dockerfiles, such as api.Dockerfile and ui.Dockerfile. When using gcloud run deploy, I want to specify which Dockerfile should be used for building the container. Specifically, I want gcloud run deploy to take only api.Dockerfile.
Here’s the directory structure:
/project-directory
├── api.Dockerfile
├── ui.Dockerfile
├── src/
└── other-files/
Is there an option with gcloud run deploy to specify a particular Dockerfile (e.g., api.Dockerfile) instead of the default Dockerfile?
No, gcloud run deploy
doesn't have an option to directly specify the docker image file name. But you can achieve this using a two-step process:
docker build
command, pass the dockerfile location and assign a
name to the image.gcloud run deploy
command with the
--container
option, specifying the name you assigned to the image in step 1.Here's an example:
docker build -t myimage -f api.Dockerfile .
gcloud run deploy --container=myimage