Docker-compose with Windows Server 2019: invalid mount config for type "bind": source path must be a directory


docker version: master-dockerrpoject-2024-01-24, build 902e9fa22b

docker-compose version: **1.29.2, build 5becea4c

OS: Windows Server 2019, 10.0.17763


    - ./configs/application.config.json:/app/application.config.json

Trying to bind a file using docker-compose file the following error occurs:
invalid volume specification: '{path}': invalid mount config for type "bind": source path must be a directory

Is there a chance that the issue resolved for Windows Server 2019 with new versions of docker?

Was it really {path} in the error message or you replaced it? It probably doesn’t matter as it seems you can’t bind mount fodlers on Windows to Windows containers even though it is supported to Linux containers.

The following examples fails when using Windows-based containers, as the destination of a volume or bind mount inside the container must be one of: a non-existing or empty directory; or a drive other than C: . Further, the source of a bind mount must be a local directory, not a file.

Although it won’T help, you should also stop using Docker Compose v1 as it was discontinued in 2023.

Use Compose v2

Hello @rimelek, thanks for response

For some reason it works with the latest Docker Desktop on Windows 10

With Windows containers? Since Linux containers support mounting a file, that would’t be a problem. What image are you trying to use and what was the image that worked on Windows 10?

I tried the same linux image. So we use the same docker compose file with same images

How do you use a Linux image on a Windows Server? Linux containers need Linux hosts. On Windows, it means you need a virtual machine. Docker Desktop could help you run a Linux container, because that creates a virtual machine, but it is not supported on a Windows server, even if someone manages to install it. If you got the error message, that means you actually tried to use a Windows container image even if it was not your intention. So what is the image you are trying to use? Or is it not something you want to share?