admin管理员组文章数量:1202371
I'm working on a docker compose where I'm trying to mount a host directory to container directory but I'm getting the following error;
docker compose up --build
Error response from daemon: invalid volume specification: '/c/Users/savi/Documents/test/test-base/vp:C:\inetpub\wwwroot:rw'
As you can see, I'm trying to mount my host directory C:\Users\savi\Documents\test\test-base\vp to container directory C:\inetpub\wwwroot
I'm on windows and running docker desktop
PS C:\Users\savi> docker compose version
Docker Compose version v2.31.0-desktop.2
docker version
Client:
Version: 27.4.0
API version: 1.47
Go version: go1.22.10
Git commit: bde2b89
Built: Sat Dec 7 10:40:21 2024
OS/Arch: windows/amd64
Context: desktop-windows
Server: Docker Desktop 4.37.1 (178610)
Engine:
Version: 27.4.0
API version: 1.47 (minimum version 1.24)
Go version: go1.22.10
Git commit: 92a8393
Built: Sat Dec 7 10:39:14 2024
OS/Arch: windows/amd64
Experimental: false
Here is my docker-compose.yaml but the issue I'm referring to is related to the iisserver
services:
sqlserver:
build:
context: ./sql/
dockerfile: dockerfile.bak
container_name: sqlserver
ports:
- "1433:1433"
environment:
sa_password: "mypassword"
ACCEPT_EULA: "Y"
volumes:
- sql_data:C:/Database
iisserver:
build:
context: ./
dockerfile: dockerfile.iisbase1
container_name: iisserver
ports:
- "8080:80"
volumes:
- C:\Users\savi\Documents\test\test-base\vp:C:\inetpub\wwwroot
depends_on:
- sqlserver
volumes:
sql_data:
driver: local
Directory: C:\Users\savi\Documents\test\test-base
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 20/01/2025 12:33 PM dbmigrator
d----- 20/01/2025 5:13 PM sql
d----- 20/01/2025 3:51 PM vp
-a---- 21/01/2025 11:23 AM 31 .env
-a---- 21/01/2025 11:15 AM 807 docker-compose.yaml
-a---- 16/01/2025 6:50 PM 1139 dockerfile
-a---- 20/01/2025 3:59 PM 1666 dockerfile.iisbase
-a---- 20/01/2025 5:10 PM 1676 dockerfile.iisbase1
-a---- 20/01/2025 3:20 PM 108 dockerfile.test
It seems to me that when picking up the host file path, it is adapting to a linux format ('/c/Users/savi/Documents/test/test-base/.) even though I'm not in the linux container mode
What I have tried..
I added the following environment variable both into the $PATH and as a .env after referring here -
echo $env:COMPOSE_CONVERT_WINDOWS_PATHS
1
Tried to add this as a bind in docker compose
volumes:
- type: bind
source: C:\Users\savi\Documents\test\test-base\vp
target: C:\inetpub\wwwroot
I also tried different way of stating the path as follows
volumes:
- "C:\\Users\\savi\\Documents\\test\\test-base\\vp:C:\\inetpub\\wwwroot"
volumes:
- "./test-base/vp:C:\\inetpub\\wwwroot"
volumes:
- "C:/Users/savi/Documents/test/test-base/vp:C:/inetpub/wwwroot"
Unfortunately, I don't have any luck so far.
Before I post here read almost all the posts that Google gave me with my prompt but I couldn't find anything solid that I could use to fix this issue
Here are some articles I have read
Any assistance on this is greatly appreciated!
I'm working on a docker compose where I'm trying to mount a host directory to container directory but I'm getting the following error;
docker compose up --build
Error response from daemon: invalid volume specification: '/c/Users/savi/Documents/test/test-base/vp:C:\inetpub\wwwroot:rw'
As you can see, I'm trying to mount my host directory C:\Users\savi\Documents\test\test-base\vp to container directory C:\inetpub\wwwroot
I'm on windows and running docker desktop
PS C:\Users\savi> docker compose version
Docker Compose version v2.31.0-desktop.2
docker version
Client:
Version: 27.4.0
API version: 1.47
Go version: go1.22.10
Git commit: bde2b89
Built: Sat Dec 7 10:40:21 2024
OS/Arch: windows/amd64
Context: desktop-windows
Server: Docker Desktop 4.37.1 (178610)
Engine:
Version: 27.4.0
API version: 1.47 (minimum version 1.24)
Go version: go1.22.10
Git commit: 92a8393
Built: Sat Dec 7 10:39:14 2024
OS/Arch: windows/amd64
Experimental: false
Here is my docker-compose.yaml but the issue I'm referring to is related to the iisserver
services:
sqlserver:
build:
context: ./sql/
dockerfile: dockerfile.bak
container_name: sqlserver
ports:
- "1433:1433"
environment:
sa_password: "mypassword"
ACCEPT_EULA: "Y"
volumes:
- sql_data:C:/Database
iisserver:
build:
context: ./
dockerfile: dockerfile.iisbase1
container_name: iisserver
ports:
- "8080:80"
volumes:
- C:\Users\savi\Documents\test\test-base\vp:C:\inetpub\wwwroot
depends_on:
- sqlserver
volumes:
sql_data:
driver: local
Directory: C:\Users\savi\Documents\test\test-base
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 20/01/2025 12:33 PM dbmigrator
d----- 20/01/2025 5:13 PM sql
d----- 20/01/2025 3:51 PM vp
-a---- 21/01/2025 11:23 AM 31 .env
-a---- 21/01/2025 11:15 AM 807 docker-compose.yaml
-a---- 16/01/2025 6:50 PM 1139 dockerfile
-a---- 20/01/2025 3:59 PM 1666 dockerfile.iisbase
-a---- 20/01/2025 5:10 PM 1676 dockerfile.iisbase1
-a---- 20/01/2025 3:20 PM 108 dockerfile.test
It seems to me that when picking up the host file path, it is adapting to a linux format ('/c/Users/savi/Documents/test/test-base/.) even though I'm not in the linux container mode
What I have tried..
I added the following environment variable both into the $PATH and as a .env after referring here -
echo $env:COMPOSE_CONVERT_WINDOWS_PATHS
1
Tried to add this as a bind in docker compose
volumes:
- type: bind
source: C:\Users\savi\Documents\test\test-base\vp
target: C:\inetpub\wwwroot
I also tried different way of stating the path as follows
volumes:
- "C:\\Users\\savi\\Documents\\test\\test-base\\vp:C:\\inetpub\\wwwroot"
volumes:
- "./test-base/vp:C:\\inetpub\\wwwroot"
volumes:
- "C:/Users/savi/Documents/test/test-base/vp:C:/inetpub/wwwroot"
Unfortunately, I don't have any luck so far.
Before I post here read almost all the posts that Google gave me with my prompt but I couldn't find anything solid that I could use to fix this issue
Here are some articles I have read
- https://github.com/docker/compose/issues/10443
- https://github.com/docker/compose/pull/4026
Any assistance on this is greatly appreciated!
Share Improve this question edited Jan 21 at 8:04 saviashan asked Jan 21 at 6:18 saviashansaviashan 11 bronze badge1 Answer
Reset to default 0This issue got fixed after setting the COMPOSE_CONVERT_WINDOWS_PATHS=0
You can add that into a .env file in the directory where your docker-compose.yaml is located.
For a quick test, you can add that into your $PATH with $env:COMPOSE_CONVERT_WINDOWS_PATHS="0"
本文标签:
版权声明:本文标题:Mounting windows directory to a windows docker container with docker compose - Error response from daemon: invalid volume specif 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738651301a2104886.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论