我想准备我的映像,但是卷和服务器名称有问题。我附加了cmd和所有代码。
catalog structure
docker-compose
main
Dockerfile
content
otherFiles
sharedDataOutput
sharedDataInput
Dockerfile
FROM microsoft/aspnet
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
WORKDIR /inetpub/wwwroot
COPY content ./
DockerCompose
version: "3.8"
services:
webapp:
container_name: My_Server_1
build: main/.
volumes:
- .\sharedDataInput:\sharedDataInput
- .\sharedDataOutput:\sharedDataOutput
ports:
- "8200:80"
cmd
C:\Fun\Docker\ContainerDockerCompose>Docker-compose up --build
Building webapp
Step 1/4 : FROM microsoft/aspnet
---> 823ecde59414
Step 2/4 : RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
---> Using cache
---> 590c945d1ae9
Step 3/4 : WORKDIR /inetpub/wwwroot
---> Using cache
---> ce618992985c
Step 4/4 : COPY content ./
---> 63e0137b4954
Successfully built 63e0137b4954
Successfully tagged containerdockercompose_webapp:latest
Creating My_Server_1 ... error
ERROR: for CDS_Server_1 Cannot create container for service webapp: invalid volume specification: 'C:\Fun\Docker\ContainerDockerCompose\sharedDataOutput:/sharedDataOutput:rw'
ERROR: for webapp Cannot create container for service webapp: invalid volume specification: 'C:\Fun\Docker\ContainerDockerCompose\sharedDataOutput:/sharedDataOutput:rw'
ERROR: Encountered errors while bringing up the project.
我尝试访问此文件
FROM microsoft/aspnet
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
WORKDIR /inetpub/wwwroot
COPY content ./
RUN icacls C:\inetpub\wwwroot\* /grant Everyone:F
仍然不起作用(也添加了此 Running a docker-compose "Getting Started" example causes "Invalid volume specification" on Windows)
C:\Fun\Docker\ContainerDockerCompose>docker-compose up --build
Building webapp
Step 1/5 : FROM microsoft/aspnet
---> 823ecde59414
Step 2/5 : RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
---> Using cache
---> c11df3b75cf4
Step 3/5 : WORKDIR /inetpub/wwwroot
---> Using cache
---> 8973084866b3
Step 4/5 : COPY content ./
---> Using cache
---> 014e59f2e51b
Step 5/5 : RUN icacls C:\inetpub\wwwroot\* /grant Everyone:F
---> Running in f186b9025583
processed file: C:\inetpub\wwwroot\Access
processed file: C:\inetpub\wwwroot\Areas
processed file: C:\inetpub\wwwroot\bin
processed file: C:\inetpub\wwwroot\Content
processed file: C:\inetpub\wwwroot\favicon.ico
processed file: C:\inetpub\wwwroot\fonts
processed file: C:\inetpub\wwwroot\Global.asax
processed file: C:\inetpub\wwwroot\Scripts
processed file: C:\inetpub\wwwroot\sharedDataInput
processed file: C:\inetpub\wwwroot\sharedDataOutput
processed file: C:\inetpub\wwwroot\Views
processed file: C:\inetpub\wwwroot\Web.config
processed file: C:\inetpub\wwwroot\WinForms
Successfully processed 13 files; Failed processing 0 files
Removing intermediate container f186b9025583
---> 4d16de798fb3
Successfully built 4d16de798fb3
Successfully tagged containerdockercompose_webapp:latest
Creating CDS_Server_1 ... error
ERROR: for CDS_Server_1 Cannot create container for service webapp: invalid volume specification: 'C:\Fun\Docker\ContainerDockerCompose\sharedDataInput:/sharedDataInput:rw'
ERROR: for webapp Cannot create container for service webapp: invalid volume specification: 'C:\Fun\Docker\ContainerDockerCompose\sharedDataInput:/sharedDataInput:rw'
ERROR: Encountered errors while bringing up the project.
也可以尝试 切换到linux conteiners并设置设置,然后又返回到Windows conteiners但还是没有帮助
答案 0 :(得分:1)
您是否在./中创建了文件夹sharedDataInput和sharedDataOutput并赋予它们正确的权限? (通常是775)
听起来您的版本找不到文件夹。
答案 1 :(得分:0)
正确答案:)即使您做出此正确设置,也无法在C:\ inetpub \ wwwroot \中装载卷:)
docker-compose(正确的代码+添加的.env文件)
version: "3.8"
services:
webapp:
container_name: Main_Server_1
build: main/.
volumes:
- .\sharedDataInput:C:\App\sharedDataInput
- .\sharedDataOutput:C:\App\sharedDataOutput
ports:
- "8200:80"
dockerfile
FROM microsoft/aspnet
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
WORKDIR /inetpub/wwwroot
COPY content ./
RUN powershell New-Item -ItemType directory -Path C:\App\sharedDataInput
RUN powershell New-Item -ItemType directory -Path C:\App\sharedDataOutput
RUN icacls C:\App\* /grant Everyone:F
RUN icacls C:\inetpub\wwwroot\* /grant Everyone:F
docker.env
COMPOSE_CONVERT_WINDOWS_PATHS=1