I'm relatively new to Docker and I'm trying to set up a cluster with three containers. Everything works fine when I run `docker compose up`, but when I modify my `docker-compose.yml` file to include a build context and then run `docker compose up --build`, I'm experiencing some strange issues with file paths. It seems like the context can't find files that are definitely present. I noticed that if I build the images manually, everything works, but when I use compose, it fails. I'm running Docker on Windows 11, and I suspect there might be an issue with how Windows paths translate to Linux paths. Can anyone help me figure this out?
5 Answers
What command are you running and from which directory? Can you describe what's in your compose file and share the exact error message you’re seeing? The more details you provide, the better we can help!
Have you tried using relative paths in your compose file? Sometimes Docker can struggle with absolute Windows paths.
From what I understand, Docker runs Linux containers inside a virtual machine when you're on Windows. So, you'll want to ensure that the context in your compose file is accessible within that VM. Your files on the C: drive may not be visible unless configured correctly.
Just a heads up, when you run the `build` command, Docker expects a Dockerfile named 'Dockerfile' unless you specify a different one using `-f`. Your command with `-f` is working because you're explicitly stating the Dockerfile name, which is good!
I don't have much experience with Docker Desktop but I found this GitHub issue that might relate to your problem: https://github.com/docker/compose/issues/11421. Check if that helps!
I've updated the main post to include more specific details.