The scenario I most feared has happened: my data-only docker container is suddenly empty.
This is not serious: it's a development machine and I have back-up. But I fear this most because I know that I still have holes in my understanding of Docker.
I have read in this answer the following:
Docker containers will persist on disk until they are explicitly deleted with docker rm.
Here are the containers I'm interested in (from a docker ps
command):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
478e59ecd218 dockerlocal_mongo_instance "/entrypoint.sh mongo" About an hour ago Exited (137) 12 minutes ago dockerlocal_mongo_instance_1
0ca49f6629cb tianon/true "/true" 3 hours ago Exited (0) About an hour ago dockerlocal_mongo_data_1
I have a 1) a mongo container which references the data-only container, and 2) the data-only container itself. I recently ran docker rm
a couple of times on the mongo dockerlocal_mongo_instance_1
container which references the data-only container.
I can see from the output of the docker ps
command (see above) that it says that the data-only container was created '3 hours ago'. But I created it about 2 weeks ago. Somehow my original one has gone. My question is how could this happen? What other possibilities are there?
I have checked my bash command history and the docker rm
command was run only on the mongo container, not on the data-only container - which for obvious reasons I have been extremely careful not to touch.
Can anyone shed any light on this? I must have misunderstood something fundamental here.
I would be grateful for any other possible scenarios that could cause the data-container to be trashed and re-created in this way.
Docker compose .yml file (relevant bits):
mongo_data:
image: tianon/true
volumes:
- /data/db
mongo_instance:
build: mongodb
volumes_from:
- mongo_data
ports:
- "27017:27017"
environment:
- MONGODB_USER=$S_USER_NAME
- MONGODB_PASS=$S_USER_PASSWORD
# command: --auth