我正在尝试使用Visual Studio的docker
支持,并希望为C:\inetpub\wwwroot\App_Data
添加卷安装。
我的Dockerfile
如下:
FROM microsoft/aspnet:4.7.1-windowsservercore-1709
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
我的docker-compose.yml
文件如下:
版本:“ 3.4”
services:
my.app:
image: ${DOCKER_REGISTRY}myapp
build:
context: .\My.App
dockerfile: Dockerfile
现在,我已经尝试在volumes
文件中指定docker-compose.override.yml
的所有变体,包括:
version: '3.4'
services:
my.app:
volumes:
- "C:\\inetpub\\wwwroot\\App_Data"
ports:
- "80"
networks:
default:
external:
name: nat
services:
my.app:
volumes:
- "C:\\temp\\dockerappdata1":"C:\\inetpub\\wwwroot\\App_Data"
ports:
- "80"
networks:
default:
external:
name: nat
services:
my.app:
volumes:
- type: volume
source: "app_data"
target: "C:\\inetpub\\wwwroot\\App_Data"
ports:
- "80"
networks:
default:
external:
name: nat
volumes:
app_data:
但是在所有情况下,我都无法运行该项目,它会报告compose
的某种配置问题,或者在启动容器时报告此问题,并显示超级无用的消息:
encountered an error during Start: failure in a Windows system call: The compute system exited unexpectedly.
正确的语法是什么?
答案 0 :(得分:1)
version: '3.4'
services:
my.app:
volumes:
- "C:\\inetpub\\wwwroot\\App_Data"
ports:
- "80"
networks:
default:
external:
name: nat
services:
my.app:
volumes:
- "C:\\temp\\dockerappdata1":"C:\\inetpub\\wwwroot\\App_Data"
ports:
- "80"
networks:
default:
external:
name: nat
services:
my.app:
volumes:
- type: volume
source: "app_data"
target: "C:\\inetpub\\wwwroot\\App_Data"
ports:
- "80"
networks:
default:
external:
name: nat
volumes:
app_data:
我认为这里的问题是,您正在尝试挂载已经存在的目录。
答案 1 :(得分:0)
如果我正确理解了您的问题,您想将“ C:\ inetpub \ wwwroot \ App_Data”卷装入容器中,对吗?
如果是这种情况,则应在yaml文件中添加以下内容:
services:
my.app:
volumes:
- C:\\inetpub\\wwwroot\\App_Data:C:\\temp\\dockerappdata1
# Syntax is HOST_PATH:CONTAINER_PATH:[ro/rw] (the access mode is optional)
ports:
- "80"
有关语法的更多信息:https://docs.docker.com/compose/compose-file/#short-syntax-3