I’m a beginner in docker / docker-compose and i’m trying to run a container from a local docker file
my dockerFolder look like this
├── docker-compose.yml
└── dockerfiles
├── dockerfile.test1
└── dockerfile.test2
What did i should put on the docker-compose file ?
I try it but it doesn’t work
version: "3.9"
services:
test1:
build: dockerfiles/dockerfile.test1
test2:
build: dockerfiles/dockerfile.test2
(I had warned that I’m a beginner)
2
Answers
You can use
context
anddockerfile
to specify a customDockerfile
name like you are doing:You can also keep the
build
but naming your filesDockerfile
and put them of two distinct directories.docker-compose does not recognize your context, the build argument requires the context (the folder where your Dockerfile is located).
to build from dockerfiles named differently, you must first specify the context and then the name of your dockerfile
as in the following example
where dockerfile is a subdirectory of parent directory wich contain the docker-compose file
check the docker-compose file reference for more details https://docs.docker.com/compose/compose-file/build/