windows上的docker工具箱装载文件 [英] docker toolbox mount file on windows

查看:372
本文介绍了windows上的docker工具箱装载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个初学者和码头工作者,我正在使用Windows机器。但是,使用卷安装文件时出现问题。该文档说明了关于OSX和Windows上的挂载文件的以下内容:



正式Docker文档:



注意:如果您在Mac或Windows上使用Docker Machine,则Docker守护程序仅对OS X / Windows文件系统的访问权限有限。 Docker Machine尝试自动共享您的/ Users(OS X)或C:\Users(Windows)目录,因此您可以使用docker run -v / Users /:/ ...(OS X)挂载文件或目录或停靠站运行-v / c / Users /:/



创建一个容量



我的Windows主机目录





使用-v选项创建docker容器

 docker run -d --name simple2 -v / c / Users / src:/ usr / share / nginx / html -p 8082:80 ng 1 



无效值C:\\Users\\src; C:\\Program Files\\ Git \\\\\\share\\\\\share\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \share\\\
ginx\html
请参阅'C:\Program Files\Docker Toolbox\docker.exe运行--help'。

检查ng1图像

 docker inspect ng1 



当我创建一个具有卷的docker容器时有什么问题?



谢谢。

解决方案

尝试运行附加的 for volume like:

  docker run -d --name simple2 -v / c / Users / src:// usr / share / nginx / html -p 80 82:80 ng1 

甚至主机操作系统,如

  docker run -d --name simple2 -v // c / Users / src:// usr / share / nginx / html -p 8082:80 ng1 

由于这个问题


这是MSYS环境将POSIX路径映射到Windows路径之前将其传递给可执行文件的东西。



I am a beginner with docker and I am using a windows machine. But I have a problem mounting files using volumes. The documentation says the following thing about mount files on OSX and windows :

Official docker docs :

Note: If you are using Docker Machine on Mac or Windows, your Docker daemon only has limited access to your OS X/Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory - and so you can mount files or directories using docker run -v /Users/:/ ... (OS X) or docker run -v /c/Users/:/

>> go to docker volumes docks

I have a small nginx Dockerfile

Dockerfile

FROM centos:6.6

MAINTAINER afym

ENV WEBPORT 80

RUN yum -y update; yum clean all

RUN yum -y install epel-release; yum clean all

RUN yum -y install nginx; yum clean all

RUN echo "daemon off;" >> /etc/nginx/nginx.conf

VOLUME /usr/share/nginx/html

EXPOSE $WEBPORT

CMD [ "/usr/sbin/nginx" ]

Creating a simple container

docker run -d --name simple -p 8082:80 ng1

8875448c01a4787f1ffe4c4c5c492efb039e452eff957391ac52a08915e18d66

Creating a container with a volume

My windows host directory

Creating the docker container with -v option

docker run -d --name simple2 -v /c/Users/src:/usr/share/nginx/html -p 8082:80 ng1

invalid value "C:\\Users\\src;C:\\Program Files\\Git\\usr\\share\\nginx\\html" 
for flag -v: bad mount mode specified 
: \Program Files\Git\usr\share\nginx\html
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

Inspecting the ng1 image

docker inspect ng1

What is wrong when I am creating a docker container with a volume?

Thanks.

解决方案

Try to run it with additional / for volume like:

docker run -d --name simple2 -v /c/Users/src://usr/share/nginx/html -p 8082:80 ng1

Or even for host OS, as

docker run -d --name simple2 -v //c/Users/src://usr/share/nginx/html -p 8082:80 ng1

Due to this issue:

This is something that the MSYS environment does to map POSIX paths to Windows paths before passing them to executables.

这篇关于windows上的docker工具箱装载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆