在windows 10 home的docker-compose.yml文件中设置卷

时间:2017-01-30 09:43:50

标签: docker docker-compose dockerfile angular2-seed

尝试设置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时,我得到:...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.

当我将其设置为C:/User/k/dev/angular-seed时,我得到...invalid volume specification...

我已检查过Oracle VM Virtual Box Manager将共享文件夹(机器文件夹)设置为:     c/Users \\?\c:\Users (auto mount) yes (Access) full

我见过的其他答案都来自:

    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.

1 个答案:

答案 0 :(得分:0)

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

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