问题描述
目前,我得到了一个在Windows主机下安装Docker卷,对我来说是一个巨大的痛苦,我无法让它工作。以下简单的Dockerfile:
FROM php:5-apache
RUN apt-get update
当我从中构建一个图像,并启动一个容器
docker build -t phisch:dev。
docker运行phisch:dev
容器正常启动。
但是当我试图安装一个卷时:
docker run -v / c / Users / phisch / dev / htdocs:/ var / www phisch:dev
将显示以下消息:
C:\Users\phisch\dev> docker run -v / c / Users / phisch / dev / htdocs :/ var / www phisch:dev
/ pre>
没有这样的文件或目录
docker:来自守护进程的错误响应:未找到或不存在的容器命令
容器中存在
/ var / www
目录,尝试其他目录不会更改结果。为主机端目录预设斜线也不会有帮助。 (// c / Users / phisch / dev / htdocs
)
如何挂载例如
/ var / www
toC:/ Users / phisch / dev / htdocs
?phisch @ DESKTOP-UC1LB9J MINGW64〜/ dev(master)
$ docker inspect phisch:dev
[
{
:sha256:73c1533222a905a378f12505ccbd9e9b34cde5a4b34ed008c39e23d5d58a9c91,
RepoTags:[
dev_web:latest,
phisch:dev,
phisch:dev3
],
RepoDigests:[],
父:sha256:d2c4149d86c4dfceaff0e9c4eb5a5d42ca7815f81dd08baad4dc8bda6db2fb10,
评论:,
创建: -10T12:16:37.667236134Z,
Container:dad811f51ef3b94d9845d13a0e43ad07ccd5684ea2747b3846accdc71abeb628,
ContainerConfig:{
Hostname:e06f5a03fe1f,
Domainname ,
User:,
AttachStdin:false ,
AttachStdout:false,
AttachStderr:false,
ExposedPorts:{
80 / tcp:{}
},
Tty:false,
OpenStdin:false,
StdinOnce:false,
Env:[
PATH = / usr / local / :/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin,
PHP_INI_DIR = / usr / local / etc / php,
PHP_EXTRA_BUILD_DEPS = apache2 -dev,
PHP_EXTRA_CONFIGURE_ARGS = - with-apxs2,
GPG_KEYS = 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3,
PHP_VERSION = 5.6.18,
PHP_FILENAME = php-
PHP_SHA256 = 54dd9106c3469bc7028644d72ac140af00655420bbaaf4a742a64e9ed02ec1b0
],
Cmd:[
/ bin / sh,
c,
apt-get update
],
ArgsEscaped:true,
Image:sha256:d2c4149d86c4dfceaff0e9c4eb5a5d42ca7815f81dd08baad4dc8bda6db2fb10,
卷:null,
WorkDir:/ var / www / html,
Entrypoint:null,
OnBuild:[],
Labels:{}
}
DockerVersion:1.10.0,
作者:,
Config:{
主机名:e06f5a03fe1f,
Domainname:,
User:,
AttachStdin:false,
AttachStdout:false,
AttachStderr:false,
ExposedPorts:{
80 / tcp:{}
},
Tty:false,
OpenStdin:false,
StdinOnce:false,
Env:[
PATH = / usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin: / bin,
PHP_INI_DIR = / usr / local / etc / php,
PHP_EXTRA_BUILD_DEPS = apache2-dev,
PHP_EXTRA_CONFIGURE_ARGS = - with-apxs2,
GPG_KEYS = 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3,
的PHP_VERSION = 5.6.18,
的PHP_FILENAME = PHP-5.6.18.tar.xz,
的PHP_SHA256 = 54dd9106c3469bc7028644d72ac140af00655420bbaaf4a742a64e9ed02ec1b0
],
Cmd:[
apache2-foreground
],
ArgsEscaped:true,
Image:sha256:d2c4149d86c4dfceaff0e9c4eb5a5d42ca7815f81dd08baad4dc8bda6db2fb10 ,
卷:null,
WorkingDir:/ var / www / html,
Entrypoint:null,
OnBuild:[],
标签:{}
},
架构:amd64,
Os:linux ,
Size:491287784,
VirtualSize:491287784,
GraphDriver:{
Name:aufs,
Data :null
}
}
]
out,容器端目录
/ var / www
需要为空,因为它有一个子目录www
码头工作者无法使用它作为安装点。解决方案可能
/
被CMD Windows shell解释为一个选项。
首先尝试一个docker-machine ssh default,以便打开你的虚拟机中的ssh会话。从那里尝试docker再次运行:
docker run -v / c / Users / phisch / dev / htdocs:/ var / www phisch:dev
正如在:
This comment mentions a&dding a second /:
docker run -v //c/Users/phisch/dev/htdocs:`/var/www` phisch:dev
Even in the docker toolbox msys shell session, there are issues (like issue 282)
After lengthy discussion, the issue was that
/var/www
had a folder in it.Mounting
/c/Users/phisch/dev/htdoc
onto an empty folder does work, but might not give the expected result, as the default CMDapache2-foreground
might still serve its content based on/var/www
(which would not havehtdocs
content if thathtdocs
is mounted onto another folder).这篇关于在使用Windows主机时如何安装Docker卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!