Search code examples
dockerlsoffigdockerfile

Mounted docker volume to host directory contains only files from the last container


I'm launching multiple linked containers. All containers mount host directory /var/log/tipsi/ to the same called internal directory. The problem I see files in /var/log/tipsi only from the last container:

  1. tipsi_solr and tipsi_erl has the same files set
  2. tipsi_web container (the last launched container) don't see files above, but only its own files
  3. host directory contains files only from the #2 (tipsi_web)

I'm launching container using fig. Here is the used config:

solr:
    build: ../tipsi_solr/
    volumes:
     - /var/log/tipsi:/var/log/tipsi
     - /home/docker/code/tipsi/solr/collection1/data

erl:
    build: ../tipsi_erl/
    volumes:
     - /var/log/tipsi:/var/log/tipsi

web:
   build: .
   volumes:
     - /var/log/tipsi:/var/log/tipsi
     - /etc/cert:/etc/cert

   ports:
     - "443:443"
     - "80:80"

   links:
     - solr:tipsi-solr.local
     - erl:tipsi-erl.local

The interesting thing - lsof shows absent files for tipsi_erl pid (launched on host):

prompt:~$ sudo lsof -p 12717
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
beam.smp 12717 root   12w   REG  252,0        0 9323763 /var/log/tipsi/stacked_cache_error.log
beam.smp 12717 root   13w   REG  252,0   739192 9323765 /var/log/tipsi/stacked_cache_debug.log

But they aren't accessible with other apps:

ls /var/log/tipsi/stacked_cache_debug.log                                                                                                             22:35:29
ls: cannot access /var/log/tipsi/stacked_cache_debug.log: No such file or directory

Also, I tried both specifying and removing VOLUME param in Dockerfile for the all containers without any luck. Any ideas why those files aren't shown?


Solution

  • I believe you're hitting https://github.com/docker/fig/issues/447

    If you added VOLUME to the Dockerfile at one point, you keep getting the contents of that volume when you recreate.

    You should fig rm --force to clear out the old containers, after that it should start working and using the host volumes.