gpt4 book ai didi

docker - 在 Windows 10 家庭版 docker-compose.yml 文件中设置卷

转载 作者:行者123 更新时间:2023-12-03 02:54:19 25 4
gpt4 key购买 nike

尝试设置 docker,以便当我在 Windows 计算机上更改项目文件时,它们会在我的 docker 容器中更新。来自 this question我了解到您应该使用 docker-compose.yml 文件中的卷设置。

但我仍然无法让它工作。

我尝试将音量设置为(+30 个类似组合):

volumes:
- x
.:/home/app/angular-seed
//c/Users/k/dev/angular-seed/:/home/app/angular-seed
c/Users/k/dev/angular-seed:/home/app/angular-seed
C:/User/k/dev/angular-seed

我还尝试添加一个 .env 文件:

COMPOSE_CONVERT_WINDOWS_PATHS=1
COMPOSE_CONVERT_WINDOWS_PATHS=0

当我执行docker-compose up

并将卷设置为.:/home/app/angular-seed 我得到:

ERROR: for angular-seed Cannot create container for service angular-seed: invalid bind mount spec "C:\\Users\\k\\dev\\angular-seed:/home/app/angular-seed:rw": invalid volume specification: 'C:\Users\k\dev\angular-seed:/home/app/angular-seed:rw' [31mERROR[0m: Encountered errors while bringing up the project.

当我将卷设置为 /c/Users/dev/angular-seed:/home/app/angular-seed 时,我得到:...包含本地卷的无效字符名称,仅允许“[a-zA-Z0-9][a-zA-Z0-9_.-]”。如果您打算传递主机目录,请使用绝对路径。

当我将其设置为C:/User/k/dev/angular-seed时,我得到...无效的卷规范...

我已检查 Oracle VM Virtual Box Manager 的共享文件夹(计算机文件夹)设置为: c/Users\\?\c:\Users(自动挂载)是(访问)完整

我看到的其他回复均来自:

    Recreating angular-seed-start
Attaching to angular-seed-start
[36mangular-seed-start |[0m npm info it worked if it ends with ok
[36mangular-seed-start |[0m npm info using npm@3.10.3
[36mangular-seed-start |[0m npm info using node@v6.6.0
[36mangular-seed-start |[0m npm info lifecycle angular-seed@0.0.0~prestart: angular-seed@0.0.0
[36mangular-seed-start |[0m npm info lifecycle angular-seed@0.0.0~start: angular-seed@0.0.0
[36mangular-seed-start |[0m
[36mangular-seed-start |[0m > angular-seed@0.0.0 start /home/app/angular-seed
[36mangular-seed-start |[0m > gulp serve.dev --color
[36mangular-seed-start |[0m
[36mangular-seed-start |[0m sh: 1: gulp: not found
[36mangular-seed-start |[0m
[36mangular-seed-start |[0m npm info lifecycle angular-seed@0.0.0~start: Failed to exec start script
[36mangular-seed-start |[0m npm ERR! Linux 4.4.43-boot2docker
[36mangular-seed-start |[0m npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"

[31mERROR[0m: Named volume "c/Users/k/dev/angular-seed:/home/app/angular- seed:rw" is used in service "angular-seed" but no declaration was found in the volumes section.

Recreating 90b0444c8ee3_90b0444c8ee3_90b0444c8ee3_90b0444c8ee3_angular-seed-start

ERROR: for angular-seed Cannot create container for service angular-seed: invalid bind mount spec "C:\\Users\\k\\dev\\angular-seed\\dev\\angular-seed:/home/app/angular-seed:rw": invalid volume specification: 'C:\Users\k\dev\angular-seed\dev\angular-seed:/home/app/angular-seed:rw'
[31mERROR[0m: Encountered errors while bringing up the project.

Recreating 90b0444c8ee3_90b0444c8ee3_90b0444c8ee3_angular-seed-start

ERROR: for angular-seed Cannot create container for service angular-seed: create \c\Users\k\dev\angular-seed: "\\c\\Users\\k\\dev\\angular-seed" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intented to pass a host directory, use absolute path
[31mERROR[0m: Encountered errors while bringing up the project.

最佳答案

docker-compose.yml 文件中尝试以下几行:

volumes:
- /c/Users/k/dev/angular-seed:/home/app/angular-seed

关于docker - 在 Windows 10 家庭版 docker-compose.yml 文件中设置卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41932778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com