I have a following project structure:
WebApp
-- docker-compose.yml
-- Dockerfile
-- docker
-- docker-gc
--Dockerfile
docker/docker-gc
is a git submodule that I have created before using this command:
git submodule add [email protected]:spotify/docker-gc.git docker/docker-gc
in docker-compose, I try to run Dockerfile in docker-gc
. Here is my service:
gc:
container_name: docker-gc
build: ./docker/docker-gc
dockerfile: ./docker/docker-gc/Dockerfile
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc:/etc
But I always receive error:
Cannot locate specified Dockerfile ./docker/docker-gc/Dockerfile
I have tried many ways such as docker/docker-gc/Dockerfile
or /docker/docker-gc/Dockerfile
without result. Is this problem related to symlink (due to git submodule nature). Please tell me how can I fix this.
The error is in your
docker-compose.yaml
file. In version 1 of that format, you can specify bothbuild
anddockerfile
. If you provide both, thedockerfile
attribute denotes the file name that is expected to be found in the directory specified bybuild
.In your case, change the
dockerfile
attribute to just include the filename instead of the same path as inbuild
:Since
Dockerfile
is the default name, you can also simply remove this line:Please refer to the Docker Compose documentation for more info.
Please also note that version 2 of the Docker Compose file format uses a different notion of the
build
parameter.