0

I've a base_image Dockerfile with a
VOLUME /var/log

Now I use the base_image in another Dockerfile as base for work_image and there is put some content in /var/log.

But if I start a container with the work_image the volume directory /var/log is empty.
The content of volume is not initialized during image creation how it is documented here:
https://docs.docker.com/engine/reference/builder/#volume

I've also tried to put another VOLUME /var/log directive in the work_image Dockerfile. But no change.

Is this as bug or how this should work?

Thx Markus

Markus
  • 101
  • How did you start the container? – Michael Hampton Jul 14 '20 at 16:03
  • @MichaelHampton With docker-compose or docker start, but there is no additional volume mount or bind. Just the single anonymous volume from the image. Seems to always mount the empty first volume from base and during build of work image, it doesn't recognize the volume from base. – Markus Jul 14 '20 at 16:21
  • I expect it's precisely because you're using an anonymous volume. These aren't really expected to be shared. I suspect each container is using a different anonymous volume. I'd poke around with `docker container inspect ` for each container and see what volumes they are using. – Michael Hampton Jul 14 '20 at 16:29
  • @MichaelHampton No, there is no sharing of volumes between containers. It is a problem of building the images. Seems that the first VOLUME definition in Dockerfile copies the directory content to a image and any later VOLUME definitions for the same directory is simply and quietly ignored. Sadly there seems to be no debug/verbose output during builds to see what is happening exactly. – Markus Jul 14 '20 at 18:06
  • Hmm, interesting. I'd like to play with this a bit. Can you share some trivial Dockerfiles that reproduce the problem? – Michael Hampton Jul 14 '20 at 18:13
  • I've created a bug: https://github.com/moby/moby/issues/41209 With the docker history of the images it should be understandable how to reproduce. – Markus Jul 14 '20 at 19:18

0 Answers0