afym
afym

Reputation: 532

Docker toolbox volumes on windows doesn't refresh changes on container

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

My host environment is a:

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:

enter image description here

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

Editing my file

enter image description here

On my browser (ctrl + f5)

enter image description here

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

enter image description here

Then I inspect my nge container with the following command.

docker inspect ng1

Docker inspect

enter image description here

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

Upvotes: 1

Views: 1813

Answers (1)

afym
afym

Reputation: 532

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

enter image description here

On Windows

enter image description here

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)

enter image description here

  • 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.

enter image description here

Upvotes: 3

Related Questions