Docker:使用Docker Toolbox在Windows上共享卷 [英] Docker: Sharing a volume on Windows with Docker Toolbox

查看:166
本文介绍了Docker:使用Docker Toolbox在Windows上共享卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Windows 7计算机上的Docker容器设置开发人员环境.

I'm trying to setup a developer environment through a Docker container on my Windows 7 computer.

我已经为Windows安装了Docker工具箱.

I've installed Docker toolbox for Windows.

我有一个包含Apache和PHP 5.6的映像,这里是:

I have an image with Apache and PHP 5.6 within, and here it is:

FROM php:5.6.15-apache

RUN apt-get update && apt-get install -y \
apt-utils vim git php5-mysql php5-memcache php5-memcached php5-intl \
wget
RUN apt-get install libapache2-mod-php5 -y -o Dpkg::Options::="--force-confdef"
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install pdo pdo_mysql
RUN apt-get install libcurl4-gnutls-dev -y
RUN docker-php-ext-install curl
RUN a2enmod rewrite

ENV APACHE_RUN_USER myname
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

EXPOSE 80

COPY php.ini /usr/local/etc/php/php.ini
COPY apache-config.conf /etc/apache2/sites-enabled/000-default.conf
RUN echo "ServerName 127.0.1.1" >> /etc/apache2/apache2.conf

此映像已创建,当我在Docker快速入门终端中运行"docker映像"时可以看到它.

This image is created, and I can see it when I run "docker images" in the Docker quickstart terminal.

在我的apache-config.conf中,我只有一个小的虚拟主机,仅使用index.php文件即可访问测试网站.

In my apache-config.conf, I just have a tiny virtual host to access a test website with just an index.php file.

然后我尝试在Docker快速入门终端中创建容器:

Then I try to create the container in the Docker quickstart terminal:

docker run --name=php5.6_container --rm -v "//c/sites:/var/www/html" -p 80:80 -p 8080:8080 php5.6

我收到以下错误:

AH00112: Warning: DocumentRoot [/var/www/html/test] does not exist
AH00112: Warning: DocumentRoot [/var/www/html/test] does not exist
[Tue Dec 08 16:36:37.703143 2015] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Tue Dec 08 16:36:37.703733 2015] [core:notice] [pid 1] AH00094: Command line: '
apache2 -D FOREGROUND'

似乎没有考虑我的音量选项.并且容器没有创建.

It seems like my volume option is not taken into account. And the container is not created.

我做错了什么?

推荐答案

有关Windows和Mac的说明,请参见

See the note for Windows and Mac at https://docs.docker.com/engine/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume. Particularly:

如果在Mac或Windows上使用Docker Machine,则Docker守护程序仅具有对OS X或Windows文件系统的有限访问权限. Docker Machine尝试自动共享您的/Users(OS X)或C:\ Users(Windows)目录.

If you are using Docker Machine on Mac or Windows, your Docker daemon has only limited access to your OS X or Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory.

基本上,您需要将站点文件移动到c:\Users\sites之类的位置,然后使用类似文档中建议的内容进行挂载:

Basically, you will need to move your site files to somewhere such as c:\Users\sites and then mount using something like suggested in documentation:

docker run --name=php5.6_container --rm -v "/c/Users/sites:/var/www/html" -p 80:80 -p 8080:8080 php5.6

这篇关于Docker:使用Docker Toolbox在Windows上共享卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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