DRIVER VOLUME NAME
local a696c50e761d87af6b1e108d7fb56d98faa1675195cc7b29dd6a5d319ec89f42
local mongodbdata
I’m baffled that I have more than 1. If I run docker-compose up
that I get two volumes, the one I created; fine, but then this other one. If I run docker-compose down
and then up
again I’ll get another volume added for 3 in total. It keeps adding another one.
One thing I’m coming around to understanding is that I should only use docker-compose up
once and the rest of the time it should be docker-compose start
or stop
and down
I guess is for when the project is likely over…I think. Still learning, but regardless of that part I’m still baffled by the two volumes, versus just the 1.
Feel free to expand or really anything on any assistance since I’m very new I’m working hard to learn as much as I can. No knowledge shared is wasted here.
Please and thank you!
Every VOLUME declared in the Dockefile of an image (regardless wether you wrote it yourself, or pull a premade image from dockerhub) will result in an anonymous volume, when no volume is mapped against the declared target folder.
There is no problem in using docker-compose up -d
to deploy or re-deploy a stack. While stop
just stops the containers of the stack, down
wil delete the containers of the stack.
@meyay hmmm I’m trying to get what you are putting down; let me see if I interpret it correct. Understand that I’m new to Docker and could totally f this up.
You are alluding to the fact that perhaps in this example the official MongoDB is producing a volume as part of it’s image instructions when I create a container and therefore I am building a container with a volume from MongoDB’s official image as well as during my docker-compose build my own volume.
Is that a correct interpretation?
Regardless thank you for what you’ve all contributed to this point. Even now I feel like I at the worst case I at least have new paths to work down towards a solution and best case I feel like I’m lots closer. Thank you.
I am saying if the image has defined volume declarations that are “unused” (as in nothing is mapped into them), then you get anonymous volumes.
You can check the volumes for an image with a command like this:
docker image inspect {imageid or name:tag} --format {{.Config.Volumes}}
Every entry you get listed requires a volume, either you provide them with your own conditions and naming or docker creates them for you.
@meyay that was a really helpful addition. I was close at the beginning with what you said, but this clarification is really perfect. I completely understand. I’ll start using that sequence of commands with this project and in the future with other Images in particular DBs.
Cheers!