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: 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=

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


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


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 ! 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr= 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr= 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr= 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr= 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr= 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=,mountvers=3,mountport=43836,mountproto=udp,local_lock=none,addr=


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


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

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.


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


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.