Docker挂载配置容器创建错误

问题描述 投票:1回答:1

我正在尝试从Docker映像为我正在处理的项目(项目人行道)创建一个容器。容器正确旋转,除了最后一步给我这个错误:

Creating projectsidewalk-db ... error                                                                                   
ERROR: for projectsidewalk-db  Cannot create container for service db: invalid volume specification: 'C:\Users\johns\OneDrive\documents\GitHub\sidewalkwebpage\db\init.sh:/docker-entrypoint-initdb.d/init.sh:rw': 
invalid mount config for type "bind": source path must be a directory

ERROR: for db  Cannot create container for service db: invalid volume specification: 'C:\Users\johns\OneDrive\documents\GitHub\sidewalkwebpage\db\init.sh:/docker-entrypoint initdb.d/init.sh:rw': 
invalid mount config for type "bind": source path must be a directory
ERROR: Encountered errors while bringing up the project.
make: *** [docker-up-db] Error 1

我查看了其他Stack Overflow线程,并尝试了修复方法,在该方法中,我创建了一个新变量COMPOSE_CONVERT_WINDOWS_PATHS并将其设置为等于1,但此方法无效。我想知道是否有人知道如何解决此问题。

docker docker-compose dockerfile mount docker-container
1个回答
0
投票

您无法在Windows上安装文件,仅允许目录。 moby中有一个问题尚未解决,因为实际上这是Windows的限制,而不是Docker的限制:https://github.com/moby/moby/issues/30555#issuecomment-279170073

总结:我想您的docker-compose.yml中有类似的内容:

volumes:
- .\db\init.sh:/docker-entrypoint-initdb.d/init.sh:rw

应该是这个:

volumes:
- .\db:/docker-entrypoint-initdb.d/:rw
© www.soinside.com 2019 - 2024. All rights reserved.