To persist data of a docker container, volume is the solution.
But I wonder what the mechanism of this implementation is.
Does docker help us to replicate container files to the host? If so, is it synchronous or asynchronous?
Related
I'm new to docker. Been reading some but still don't get it much. Basically if I mount a volume it will be persistent on my hard drive so that my container service can write down and save datas. Seen a lot of container services that is mounted with volumes, like jenkins. But If I have mariadb, do I need to mount a volume to it? What happens if I stop and start the mariadb container?
If you just stop and start the data will not be lost.
All data will be deleted when you delete and recreate the container.
Answering your question. It is not strictly necessary to mount a volume for a persistent service (e.g: database). But it is a recommended practice, it will ease scenarios like changing the container (upgrading).
I run a complex app with a database backend and many other things all in one container. I notice that Docker images for different database systems are available. When would I want to move something like a DB server to its own container, instead of running everything in the same container? The advantage I have now is that I can deploy everything at once, and I don't have to configure more than one container to get things talking.
Docker or the Container Manager is using Linux container technology to provide a best abstraction, using docker container with multiple process is a bad idea; use docker container for isolating one process, use docker volume container for storing database data ( docker state is not persistent by default).
Use docker-compose or fig to attach two docker containers db and web app, it will ease your management in future!
There are many containers that'll attach to the docker socket, enumerate the volumes, and back up the contents, but how do I orchestrate this together with a container that may be in the middle of writing or presumes it has exclusive access to the file(s)? I'm thinking of SQL Server or Minecraft or another stateful data store that may trickle data in periodically in unpredictable ways. Is there a strategy for grabbing transactionally consistent data from a docker volume for backup? Or is there a way to tell one container to pause / stop another container during the backup operation?
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:
Can data volume containers be used/mounted in containers residing on other hosts within a docker swarm?
How is the performance? is it recommended to structure things this way?
Is there a better way to handle sharing of persistent resources across containers and hosts such as NFS?
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.
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.
Is it possible to mount Cinder volumes on docker containers in openstack?
And if it is, is there a way to encrypt data leaving the container to the cinder volume?
I was thinking of mounting the volume as a loopback device and encrypt the data as it was being flushed to the disk. Ist this possible?
Kind regards
It is not currently possible to mount Cinder volumes inside a Docker container in OpenStack.
A fundamental problem is that Docker is filesystem-based, rather than block-device-based. Any block device -- like a Cinder volume -- would need to be formatted with a filesystem and mounted prior to starting the container. While it might be technically feasible, the necessary support for this does not yet exist.
The Manila project may be a better solution for adding storage to containers, but I haven't looked into that and I don't know if (a) the project works at all yet and (b) it it works with nova-docker.
If you're not using the nova-docker driver but are instead using the Heat plugin for Docker, you can mount host volumes in a container similar to docker run -v ..., but making this work seamlessly across multiple nodes in a multi-tenant setting may be difficult or impossible.