34
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker for windowsをgit bashで使うときの-v(volume)の指定の仕方

Last updated at Posted at 2018-04-26

環境はwindows 10で、ターミナルはGit Bashを使用しています。

docker for windows(Hyper-V)を使用しているのですが、
VirtualBoxでdockerを利用してたときのように下記コマンドを打ったのですが、起動しませんでした。

$ winpty docker run -v `pwd`:/var/app -it alpine

C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: Mount denied:
The source path "C:/Users/username;C"
doesn't exist and is not known to Docker.
See 'C:/Program Files/Docker/Docker/Resources/bin/docker.exe run --help'

正しいコマンド?

# //c/any/directory を指定
$ winpty docker run -v /$PWD:/var/app -it alpine
$ winpty docker run -v /`pwd`:/var/app -it alpine
# C:\any\directory を指定
$ winpty docker run -v `pwd -W`:/var/app -it alpine

指定しているパスが/始まりだと起こるようで上記のように、
pathの先頭もう一つ/をつけるか(例://c/any/directory)
windows形式のpathを指定(例:C:\any\directory)
のどちらかを指定すれば大丈夫のようです。

備考

pathがアレなのはMinGWの仕様のようです。
http://www.mingw.org/wiki/Posix_path_conversion

34
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?