When it comes to Docker containers, storage has been a popular topic, especially around persistent storage and data volumes. Last week, we hosted a webinar with Mike Coleman, Technical Marketing Engineer at Docker, Inc. In this webinar, Mike completed the third webinar in his three-part saga around storage and Docker.
Q: Is it possible to create a volume with the docker-compose file?
Absolutely. You can find out exactly how in the Dockerfile command reference docs.
Q: Can you attach 1 volume to different containers? what happens then with write access?
Yes, you can. But, you (or your app) need to take care of making sure that writes are handled correctly. Docker itself won’t manage simultaneous writes to a file, if one container writes to the file, and another rewrites it – Docker won’t stop that. You’ll need to make sure that you account for that in your application.
Q: Can you limit the size of a volume?
No. Any sort of quotas you want to assign would need to be supported by your application.
Q: (in mac) is it possible to share a folder with the vm and use it to create a volume, so the data is on the mac and not in the vm?
Yes. You can do this today if you use Docker machine. Add -v /local_dir:/container_dir when you start your container. Or you can use the Kitematic UI to mount a volume.
Q: Will there be a set of storage plugins officially supported by Docker, or will they all be provided by third parties?
Docker does ship a default storage plugin today. As for integration with 3rd parties, we expect these to be vendor (or community) supplied for the forseeable future.
Q: Are data only container “deprecated” then?
You can still use the –volumes_from flag to map in a volume from another container (a so-called data-only container), but you lose a lot of the visibility and manageability that comes from using the newer named volumes support.
Q: if we delete the container then the data will be gone ?
If your data is not stored in a volume, then yes – when you delete the container you will lose the data. If the data is stored in a volume, and you don’t delete the volume explicitly when you delete the container, the data will persist.
Q: How can you share that volume across multiple docker hosts?
Docker cannot do this natively today. Various volume plugins could help address this use case. Flocker for instance will migrate volumes between hosts as needed.
Q: Can I create volumes inside the container on the fly (considering I know the host directory I want), as I understand docker mounting use lxc mount option and we cannot do once inside.
Volumes need to be created before a container is instantiated. You cannot, today, hot mount volumes to a running container.
Q: Is it possible to run multiple volumes with different DB structures, say MongoDB on one and PostGres on another?
Yes. Each volume is independent of any other volume running on the host.
Q: What is the best way to backup container/volumes docker in case of crash of the host to recover to another host?
Essentially you backup the host directory housing your volumes. See the Docker docs for more info (near the bottom of the page).
We hope the answers to these questions provide you with insight you need around storage and Docker. The resources below provide more information that you might find helpful. As always, you can reach out to us with any questions.
Sign up for a free 30-day trial of Docker Subscription to get the essential software, support and security you need.
Learn More about Docker
- New to Docker? Try our 10 min online tutorial
- Share images, automate builds, and more with a free Docker Hub account
- Sign up for a free 30 day trial of Docker
- Read the Docker 1.9 Release Notes
- Subscribe to Docker Weekly
- Register for upcoming Docker Webinars and Docker Online Meetups
- Attend upcoming Docker Meetups
- Watch DockerCon EU 2015 videos
- Start contributing to Docker