F
F
furyon2016-03-24 10:08:27
LXC
furyon, 2016-03-24 10:08:27

How to properly use Docker data volumes?

Hello!
In the principle, I figured out how to use "data volumes" and what they are for, but I don't understand why, for the place where the data volumes container is created, do not use the -v some_dir:some_dir.
Examples for Postgres (docker-compose)
1. data volumes:

postgres:
  image: postgres:9.5
  volumes_from:
    - postgres-data

postgres-data:
  image: busybox
  volumes:
    - /var/lib/postgresql/data

2. volumes:
postgres:
  image: postgres:9.5
  volumes:
    - ./volumes/postgres:/var/lib/postgresql/data

What I see are the advantages of the 2nd approach:
1. To make a copy, you don't have to worry about creating another container and running a command in it. A copy is always in front of your eyes. The same goes for restoring data to a container.
2. Fewer containers created.
3. Less letters in docker-compose.
4. I may be wrong, but I had a case when, as I understood, unnecessary data volumes filled me with a lot of disk space (probably I just did something wrong).
What I see are the disadvantages of the 2nd approach:
1. Surely this folder will be in your working environment, and you can inadvertently do something with it. Those. there is no isolation.
What else am I not considering, and what should I choose?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4Proof, 2016-09-20
@4Proof

Everything is painted correctly, but the 1st method has its advantages (such as relocation, for example)
d3vil.me/persistent-docker-data-containers - here is some more information about the differences

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question