Available options
- In container (default)
- Cons:
- not reliable: data loss on container re-creation
- hard to use: not easy to read/write data
- Cons:
- In docker volume
- Cons:
- hard to use: not easy to read/write data
- Cons:
- In mounted folder
- Cons:
- pollutes work folder
- issues with permissions in mounted folder
- Cons:
Based on considerations above we chose to use named local volumes.
This is how it looks:
$ docker volume ls
DRIVER VOLUME NAME
local cmltemplate-mongo_mongo_configdb
local cmltemplate-mongo_mongo_data
local cmltemplate-rabbit_rabbit_data
(In real usage it will be real_project_name
instead of cmltemplate
).
If you want to reach physical location of a volume's data just do
cd "$(docker volume inspect cmltemplate-mongo_mongo_data \
| jq -r '.[0].Mountpoint')"
You might need sudo
though to access the files.
We considered an approach to map the config files of a service to the host folder for ease of change. But this causes more complexity than we want:
- Aforementioned permissions issues
- Unneeded flexibility that can be unsustainable
So instead it's better to try to configure the services via it's .yml file:
- environment vars
- command (i.e. see how we've set up the slow log for mysql)
TODO, see https://stackoverflow.com/questions/30233105/docker-compose-up-for-only-certain-containers
docker ps # list running containers
docker ps -a # list all containers
docker volume ls # list volumes
DANGER!!! USE WITH CARE!!! THIS WILL CAUSE DATA LOSS!!!
# rm all containers
docker rm -f $(docker ps -a -q)
# rm all volumes
docker volume rm $(docker volume ls -q)