0

I have two container one is setup as a data volume, I can go inside the data container and explore the files that are mounted from a network share with out any issues.

how ever on the second docker instance when I go to the folder with mounted volumes the folder exists but all the files and directories that should be there are not visible.

this used to work so I can only assume its due to docker 1.9 I am seeing this on a linux and mac box.

Any ideas as to the cause ? is this a bug or is there something else i can investigate ?

output of inspect.

    "Volumes": {
        "/mnt/shared_app_data": {},
        "/srv/shared_app_data": {}
    },

    "Mounts": [
    {
        "Name": "241d3e495f312c79abbeaa9495fa3b32110e9dca8442291d248cfbc5acca5b53",
        "Source": "/var/lib/docker/volumes/241d3e495f312c79abbeaa9495fa3b32110e9dca8442291d248cfbc5acca5b53/_data",
        "Destination": "/mnt/shared_app_data",
        "Driver": "local",
        "Mode": "",
        "RW": true
    },
    {
        "Name": "061f16c066b59f31baac450d0d97043d1fcdceb4ceb746515586e95d26c91b57",
        "Source": "/var/lib/docker/volumes/061f16c066b59f31baac450d0d97043d1fcdceb4ceb746515586e95d26c91b57/_data",
        "Destination": "/srv/shared_app_data",
        "Driver": "local",
        "Mode": "",
        "RW": true
    }
],

the files are mounted in the docker file in this manner

RUN echo '/srv/path ipaddress/255.255.255.0(rw,no_root_squash,subtree_check,fsid=0)' >> /etc/exports
RUN echo 'ipaddress:/srv/path /srv/shared_app_data  nfs defaults 0 0' >> /etc/fstab
RUN echo 'ipaddress:/srv/path /mnt/shared_app_data  nfs defaults 0 0' >> /etc/fstab

and then when the container starts it runs.

service rpcbind start
mount -a 
Oly
  • 370
  • 5
  • 16

1 Answers1

0

You need to be sure that the second container does mount the VOLUME declared in the first one

docker run --volumes-from first_container second_container

Make sure the first container does have the right files: see "Locating a volume"

docker inspect first_container
# more precisely
sudo ls $(docker inspect -f '{{ (index .Mounts 0).Source }}' first_container)
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have added the results from inspect, also running sudo docker exec -it first_container ls -la /mnt/shared_app_data correctly lists all the files – Oly Dec 18 '15 at 10:24
  • @Oly does your second container runs with the --volume-with option? – VonC Dec 18 '15 at 10:47
  • no i do not use volume-with i have not come across that option before, the second container launches with --volumes-from first_container – Oly Dec 21 '15 at 10:49
  • @Oly sorry, I meant volumes-from, not volumes-with. Does the first container declares a VOLUME in its dockerfile? – VonC Dec 21 '15 at 11:18
  • yes I have these in the docker file VOLUME /srv/shared_app_data VOLUME /mnt/shared_app_data which matches the inspect results above. – Oly Dec 21 '15 at 11:19
  • @Oly does that same Dockerfile includes soem ADD/COPY directives which account for the content you see when looking at the first container? That same content should be visible in the second container (since it mounts the data container with the --volumes-from) – VonC Dec 21 '15 at 11:21
  • It has a single add command which adds a script to a completely different folder, and like I say the first container seems to be fine because the volumes exist with files in when I look inside the container. – Oly Dec 21 '15 at 11:28
  • @Oly how is the first container launched though: is it mounting an host folder to the volume path? (`-v hotst/path:/vollume/path`) – VonC Dec 21 '15 at 11:30
  • no the first container is mounting a network share inside the container, its not mounting a path outside the container. the idea being I can access the share from multiple container. – Oly Dec 21 '15 at 12:06
  • @Oly How does that first container mount the network share? What command are you using? What option? – VonC Dec 21 '15 at 14:17
  • Added the mounts to the question – Oly Dec 22 '15 at 08:30
  • @Oly OK. I was only familiar with mounting volumes with the --volumes-from option. I never explicitly mount shared folder in a container/image. – VonC Dec 22 '15 at 08:33
  • no problem, it just so you dont have to mount in every container which creates an overhead when you need to update something. its more annoying that it did work at some point and then seemed to just stop working. – Oly Dec 22 '15 at 08:40
  • unfortunately not, I think that refers to locally mounted volumes not volumes mounted inside a container. the the mounting works its just the link to new container that does not work. – Oly Dec 22 '15 at 09:20