Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Data Volume Container - Can I share across swarm

Tags:

I know how to create and mount a data volume container to multiple other containers using --volumes-from, but I do have a few questions regarding it's usage and limitations:

Situation: I am looking to use a data volume container to store user uploaded images in for my web application. This data volume container will be used/mounted by many other containers running the web frontend.

Questions:

  1. Can data volume containers be used/mounted in containers residing on other hosts within a docker swarm?

  2. How is the performance? is it recommended to structure things this way?

  3. Is there a better way to handle sharing of persistent resources across containers and hosts such as NFS?

like image 387
deankarn Avatar asked Jun 09 '15 21:06

deankarn


People also ask

Can you share data between Docker containers using Docker volume?

Sharing and persisting data in Docker containers is handled by Docker Volumes. Docker Volumes can be created during container creation or created later and attached to containers. In this tutorial, we will be discussing the four different ways to share data between containers.

How do volumes work with Docker Swarm?

Swarm Mode itself does not do anything different with volumes, it runs any volume mount command you provide on the node where the container is running. If your volume mount is local to that node, then your data will be saved locally on that node.


2 Answers

Can data volume containers be used/mounted in containers residing on other hosts within a docker swarm?

Docker, by itself, does not provide any facility for either migrating data or sharing data between hosts in a cluster.

How is the performance? is it recommended to structure things this way?

Docker volumes impose very little performance overhead in general, because they're just bind mounts.

Is there a better way to handle sharing of persistent resources across containers and hosts such as NFS?

NFS or any cluster filesystem, such as gluster, can be used to create data volumes that are available to all hosts in a cluster.

like image 103
larsks Avatar answered Sep 18 '22 21:09

larsks


There is a technology called as Flocker which will help you to move your containers across the hosts with the attached volume. Flocker is open source. Docker in itself doesn't provide any functionality for Docker container migration. There is a small article on container migration. Hope it will be helpful.

like image 39
Bithin Alangot Avatar answered Sep 17 '22 21:09

Bithin Alangot