1

docker run has a flag --volumes-from which allows you to mount a volume from another container.

I see that people create a dedicate container just for the sake of providing a volume for another container. Is this an anti-pattern and the best-practice should be creating a named volume with docker volume create --name?

Can someone shed some light on why creating a dedicate container just for the sake of volume can be beneficial? Could it be for the scenario when it's used in orchestration with Docker Machine/Docker Swarm/Kubernetes?

LxL
  • 113
  • 2

1 Answers1

0

My reason list :

1) imagine you have a really complicated stack with a lot of containers, you can imagine it is faster to do the volume setup in 1 docker, and herit this setup with a --volumes-from directive for all other dockers

2) as I'm running docker in production, I have static data that I have to backup to tapes. on each stack, I just need to add 1 docker running a backup software client image with --volumes-from, and I am done backuping all the static data from all the stack. This also made things easy when I had to delegate the data backup scheduling/triggering to the stack end user.

Chaoxiang N
  • 1,283
  • 5
  • 11