mongo icon indicating copy to clipboard operation
mongo copied to clipboard

trouble with persistent docker volumes

Open DanielLaubacher opened this issue 9 years ago • 1 comments

I'm using this image as part of a docker-compose v2 file. I have a volume for this image setup like so:

image: mongo 
volume: 
  my-volume:/data

If I inspect the contents of my-volume it only shows the files 'db' and 'configdb'. If I run docker volume ls I can see two volumes that are created as part of the image in the dockerfile /data/db and /data/configdb. They are unnamed volumes. I can see the contents of those volumes, the mongo database as expected. I had assumed that the contents of those volumes would be mounted in my-volume. But this doesn't seem to be the case as my-volume only contains the empty folders 'db' and 'configdb'. Is it expected that you can't nest docker volumes? If so what is the correct method for updating this image? I had planned to run docker-compose up --build to update the image. However this created new unnamed volumes. In the end I'm really asking how is this image intended to be used and updated. Should I stick to running docker-compose start/stop ?

Thanks.

DanielLaubacher avatar Mar 20 '17 21:03 DanielLaubacher

Yeah, with Docker you cannot nest volumes. You'll have to specify the same path as the volume:

volume:
  my-volume:/data/db

The configdb folder should only matter if you are running a config server.

Duplicate of https://github.com/docker-library/mongo/issues/104.

yosifkit avatar Apr 11 '17 17:04 yosifkit