docker COPY不在C驱动器中时全部失败 [英] docker COPY all fails when not in C drive

查看:44
本文介绍了docker COPY不在C驱动器中时全部失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我在Windows 10上,使用docker-machine / virtual box



我有一个项目可以在上正常运行C:\ 驱动器。



如果我将所有文件复制到第二个硬盘中,则 F:\ COPY。 Dockerfile中的/ path 命令似乎成功,但是当我检查容器中的目录为空时。



我的docker文件;

 从php:7.3-apache-stretch 

运行docker-php-ext-install pdo_mysql \
&& a2enmod重写协商

复制docker / php / php.ini /usr/local/etc/php/php.ini
复制docker / apache / vhost.conf / etc / apache2 / sites- available / 000-default.conf
COPY。 / srv / app

工作目录/ srv / app

我的docker-compose .yml文件;

 版本: 3 
服务:
应用程序:
构建:。
端口:
-8080:80
数量:
-。:/ srv / app

这里奇怪的是前两个 COPY 命令有效

 复制docker / php / php.ini /usr/local/etc/php/php.ini 
复制docker / apache / vhost.conf / etc / apache2 / sites-available / 000-default.conf

我可以导航到这两个目录,并通过右侧分别查看两个文件内容。一些资源表明该容器无权访问我的第二个驱动器,但显然可以,否则这些文件也将不起作用。



仅供参考,我在使用以下命令构建并检查容器

  docker-machine up -d --build 
docker-machine exec应用bash
ls

更新
如果我更改副本到 / var / www / html 文件夹中,该命令即可正常运行。我目前仅将文件放在 / srv / app 中,因为我一直在关注本教程。在这个阶段,我尚不清楚它的优缺点。






解决方案
感谢@LinPy,我使用此注释来帮助我进行正确的设置:

解决方案

尝试一下:

  docker-machine stop 

vboxmanage sharedfolder添加默认--name project_name --hostpath< full_project_path> --automount

docker-machine start

然后配置 mount

 音量:
-/ project_name:/ path / in / container / project_name

如果没有帮助,请尝试以下操作:

  docker-machine create -d virtualbox --virtualbox-share-folder \\?\f:\paht1\path2:installdir test2 

您还可以看到问题


NOTE: I'm on windows 10, using docker-machine / virtual box

I have a project which builds and runs just fine when on my C:\ drive.

If I copy all files to my second hard drive F:\ the COPY . /path command in my Dockerfile appears to succeed, however when I inspect that directory in the container it's empty.

My docker file;

FROM php:7.3-apache-stretch

RUN docker-php-ext-install pdo_mysql \
    && a2enmod rewrite negotiation

COPY docker/php/php.ini /usr/local/etc/php/php.ini
COPY docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY . /srv/app

WORKDIR /srv/app

My docker-compose.yml file;

version: '3'
services:
  app:
    build: .
    ports:
      - 8080:80
    volumes:
      - .:/srv/app

The odd thing here is that the first two COPY commands work

COPY docker/php/php.ini /usr/local/etc/php/php.ini
COPY docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf

I can navigate to those two directories and see the two files individually with the right content. Some resources suggest the container does not have access to my second drive, but it clearly does, else these files would also not work.

FYI I'm using the following to build and then inspect the container

docker-machine up -d --build
docker-machine exec app bash
ls

UPDATE If I change the copy folder to /var/www/html the command works properly. I'm currently only putting the files in /srv/app because I've been following tutorial. I'm not aware of the advantage/disadvantage of this at this stage.


SOLUTION Thanks to @LinPy I used this comment to help me get the right setting: https://github.com/docker/machine/issues/3908#issuecomment-412385611

I opened a command prompt in C:\Program Files\Oracle\VirtualBox and ran the following command.

VBoxManage.exe sharedfolder add default --name "/f" --hostpath "f:\\" --automount

My VirtualBox settings now looks like this;

解决方案

try this :

docker-machine stop

vboxmanage sharedfolder add default --name "project_name" --hostpath "<full_project_path>" --automount

docker-machine start 

then configure the mount

volumes:
  - /project_name:/path/in/container/project_name

when that did not help, try this:

docker-machine create -d virtualbox --virtualbox-share-folder "\\?\f:\paht1\path2:installdir" test2

you can see also this issue

这篇关于docker COPY不在C驱动器中时全部失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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