Data Volume from Dockerfile & use, clarification need

In my Docker file I have those declarations:

ADD ./dist/MSF_aaa.tgz /home/MSF/
VOLUME ["/home/MSF"]

When I type :
docker run -i -t < IMAGE ID> bash
I see the untar of my archive, that’s fine.
I edit a file in this volume, and set a parameter.
I quit and restart with the same command, i lost the parameter settings.

I thought i should be saved.

I also tried with :
docker run -i -v /home/MSF -t < IMAGE ID> bash

it’s the same, parameter lost.
when typing mount I see:
10.229.190.151:/users/docker/vfs/dir/67241258442e73ae4aff589f058e162db9684aa7c5741096c611df1a427bbab5 on /home/MSF type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)

I don’t understand why I lose my modification.
thanks for helping me.
marc

Hi,

Why is your Docker Volume shown as an NFS mount? Are you using any of the latest Docker Volume plugins features ?

Regards

Hi
I did nothing ‘special’ ! (or I just follow the tutorials about volumes in Dockefile)
Everything that I did is is my first post.
my Docker version is 1.3.2, build 39fa2fa/1.3.2, distrib is Centos 7.

Some other files are also mounted (see below; /var/lib/mysql is declared the same way MSF is):
I thought it was normal !

10.229.190.151:/users/docker/containers/0e0539051396fad0c009dd4741dd3cb9742812a7805925ec7b131e1746ddc02b/resolv.conf on /etc/resolv.conf type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)
10.229.190.151:/users/docker/containers/0e0539051396fad0c009dd4741dd3cb9742812a7805925ec7b131e1746ddc02b/hostname on /etc/hostname type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)
10.229.190.151:/users/docker/containers/0e0539051396fad0c009dd4741dd3cb9742812a7805925ec7b131e1746ddc02b/hosts on /etc/hosts type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)
10.229.190.151:/users/docker/vfs/dir/3de351fd8b91f13a15765c7b909fa0aa7af3c441a508ad6459bbe1418f9478b5 on /home/MSF type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)
10.229.190.151:/MSF/Download/vtk on /usr/local/vecsys/trans type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)
10.229.190.151:/users/docker/vfs/dir/809ea35b9527b838806bcef598bb4fb59a8427d0e0bad43676eebe86e849a50c on /var/lib/mysql type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.229.190.151,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=10.229.190.151)

Hi,

Are you sure your docker version is 1.3.2? Then you should seriously consider upgrading to the latest version of docker which is 1.8.2. You can make use of the Docker yum repositories http://yum.dockerproject.org/repo/ for installation.

Anyway there is a mistake in the way you are doing Docker volumes. Can you please upgrade Docker to latest version so that we are on the same page.

Regards

Hi
Upgrade in progress…
dependencies, dependencies, what a joy :-o
I let you know when it’s done :wink:
thanks

Hi,
Now i’m with an updated centos 7 & Docker version 1.8.2, build 0a8c2e3
I built the container again (all previous docker containers were lost in the upgrade).
It’s exactly the same, nfs shares & no persistance :frowning:
Exactly like before.
thanks
marc

Hi,

Is your /var/lib/docker on your host a network share(nfs) ?

Now regarding your issue. When you define a VOLUME in Dockerfile, you are just provisioning a mount point to attach a volume (a directory from host). Just defining VOLUME in Dockerfile wont make that location in your container to persist data.

Similarly when you use -v in a docker run ... again your are provisioning the mount point. To really get the persistence you should mount a host directory to this mount point.

eg: docker run -it --rm -v /my-vol-dir-on-host:/home/MSF centos:7 /bin/sh now you can write anything to the /home/MSF directory in your container and it will actually gets written to the host directory. And when you rerun the container with same command, you can see the data in the same location inside the container.

This is how persistence works in Docker.

In your dockerfile after adding MSF_aaa.tgz to /home/MSF you should not expose that as VOLUME as when you mount another directory over /home/MSF at the time of docker run the local folder will be mounted over /home/MSF and your contents of MSF_aaa which got extracted to /home/MSF will be lost

Regards

Hi
Yes I put /var/lib/docker on a nfs share, I had no space left on hd (i forget that).
I guess that’s why we see volume as a nfs share.
Now the persistency is much clearer.
Thank you very much for your help.
marc