Windows上的Docker工具箱卷无法刷新容器上的更改

编程入门 行业动态 更新时间:2024-10-25 01:27:03
本文介绍了Windows上的Docker工具箱卷无法刷新容器上的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从Windows上的docker开始,并且尝试使用卷来管理容器中的数据.

我的主机环境是:

  • Windows 8.1
  • Docker Toolbox 1.8.
  • Virtual Box 5.0.6

我已经使用以下Dockerfile创建了ngnix映像.

Dockerfile

来自centos:6.6维护者环保网80运行yum -y update;百胜清理所有运行yum -y install epel-release;百胜清理所有运行yum -y install nginx;百胜清理所有RUN echo守护程序关闭";>>/etc/nginx/nginx.conf卷/usr/share/nginx/html曝光$ WEBPORTCMD ["/usr/sbin/nginx"]

我使用以下命令创建了一个ngnix容器.

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

然后我进入浏览器,然后可以看到该网页:

但是,当我对index.html文件进行更改时,它不会在浏览器上刷新

编辑我的文件

在我的浏览器上(Ctrl + F5)

我去VirtualBox机器检查我的共享目录选项是否正常.

然后我使用以下命令检查我的nge容器.

码头工人检查ng1

Docker检查

卷发生了什么?为什么我看不到自己的更改?

解决方案

几天后,我可以找到解决方案.

即使在MAC上,Windows上的第一个docker也使用VirtualBox上的 boot2docker 实例.

在MAC上

在Windows上

接下来,码头工人的官方文件说:

  • 加入默认计算机,并使用别名安装目录

sudo mount -t vboxsf别名-virtualbox some-path-in-boot2docker#就我而言(boot2docker实例)$ CD$ mkdir arquitectura$ sudo mount -t vboxsf arquitectura/arquitectura

  • 最后创建一个新容器,或者如果您未更改c/user/路径,则重新启动现有容器

#就我而言(docker客户端)$ docker run -d --name nge -v//arquitectura/src:/usr/share/nginx/html -p 8081:80 ng1

现在可以使用了.

I am starting with docker on windows and I am trying to use volumes for manage data in containers.

My host environment is a:

  • Windows 8.1
  • Docker Toolbox 1.8.
  • Virtual Box 5.0.6

I've created a ngnix image using the following 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" ]

I've created a ngnix container using the following command.

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

Then I go to my browser and I can see the web page:

However when I make a change on my index.html file it doesn't refresh on browser

Editing my file

On my browser (ctrl + f5)

I went to the VirtualBox machine to check if my shared directories options is ok.

Then I inspect my nge container with the following command.

docker inspect ng1

Docker inspect

What is happening with volumes? Why I can not see my changes?

解决方案

After a couple of days I could find the solution.

Firstable docker on windows even on MAC uses a boot2docker instance on VirtualBox.

Diagrams

On MAC

On Windows

Next, the official docker's documentation says :

docker volume

Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory

However, after find a solution I decided to change the default c/Users to another path just for keep order. With this in mind I did the following steps:

  • Define your own workspace directory. In my case is /e/arquitectura (optional. If you want you can use the default path which is /c/Users)
  • Verify the configuration on the Virtual Machine (In default machine go to > Configuration > Share directories)

  • Join to the default machine and mount the directory using the alias name

sudo mount -t vboxsf alias-name-virtualbox some-path-in-boot2docker # In my case (boot2docker instance) $ cd $ mkdir arquitectura $ sudo mount -t vboxsf arquitectura /arquitectura

  • Finally create a new container or restart an existing one if you haven't changed the c/user/ path

# In my case (docker client) $ docker run -d --name nge -v //arquitectura/src:/usr/share/nginx/html -p 8081:80 ng1

Now it works.

更多推荐

Windows上的Docker工具箱卷无法刷新容器上的更改

本文发布于:2023-11-17 05:22:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608975.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工具箱   容器   Windows   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!