Skip to content

Conversation

myspotontheweb
Copy link
Contributor

@myspotontheweb myspotontheweb commented Sep 4, 2019

The main issue I have with using local directories for container persistence is that

  1. Files created are owned by root.
  2. The files are typically binary and not editable or interesting to a programmer in any way
  3. Random "data" directories just a bit ugly in the filesystem :-(

I have discovered that docker-compose can hand-off the management of volumes to the docker engine instead. For example after running the examples associated with this PR, you can see that Docker has created 3 volumes:

$ docker volume list
DRIVER              VOLUME NAME
local               mongo_dbdata
local               mysql_dbdata
local               postgres_dbdata

To conclude I like how this approach elegantly hides away the messy details of persistence. Easy to cleanup the volume used by passing the "-v" option

docker-compose down -v

@kodemaan
Copy link

kodemaan commented Sep 4, 2019

Just curious would all these different database engines sharing the same volume cause any issues? I'm sure they use a different folder structure but might be worth looking into

@myspotontheweb
Copy link
Contributor Author

myspotontheweb commented Sep 4, 2019

They don't share the same volume. If you use Docker to list the volumes you'll see each project creates a volume called projectname_dbdata

$ docker volume list
DRIVER              VOLUME NAME
local               mongo_dbdata
local               mysql_dbdata
local               postgres_dbdata

@kodemaan
Copy link

kodemaan commented Sep 4, 2019

They don't share the same volume. If you use Docker to list the volumes you'll see each project creates a volume called projectname_dbdata

$ docker volume list
DRIVER              VOLUME NAME
local               mongo_dbdata
local               mysql_dbdata
local               postgres_dbdata

Alright didn't know that cool :)

Copy link
Owner

@alexmacarthur alexmacarthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A welcome improvement! I had been relatively unfamiliar with managed volumes -- I see the benefits over clogging up the filesystem with data directories.

@@ -1 +1 @@
data
docker-compose.override.yml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. 👍

@alexmacarthur alexmacarthur merged commit 1f23c0a into alexmacarthur:master Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants