What is the most appropriate (smallest, simplest) container to use for a data only Docker container?
In the documentation they use the training/postgres container. However, I believe another container will actually run the database (e.g. postgres).
http://docs.docker.com/userguide/dockervolumes/
I assume a data container would be very minimal since it is usually only there to provide the data volume for another container.
Perhaps the container is ignored when creating a data-only container?
Therefore a "data-only container" is a container whose only purpose is to have a data volume attached, which is used by the --volumes-from flag in a docker run command. For example: docker run -d --name "mysql-data" -v "/var/lib/mysql" alpine /bin/true. When the above command is run, a "data-only container" is created.
Simply put data containers are containers whose job is just to store/manage data. Similar to other containers they are managed by the host system. However, they don't show up when you perform a docker ps command. To create a Data Container we first create a container with a well-known name for future reference.
Docker has two options for containers to store files on the host machine, so that the files are persisted even after the container stops: volumes, and bind mounts. Docker also supports containers storing files in-memory on the host machine.
Container Data Volume. Data volumes are the preferred mechanism for persisting data generated by and used by Docker containers. Data Volumes are essentially directories or files in the Docker Host filesystem that can be mounted directly into the container's filesystem.
Update: Now that we have named volumes, you generally don't want to use data containers at all.
Use the same image for the data container - in this case the Postgres image. You don't leave data containers running, so it won't consume resources.
Using the same image is important for several reasons:
For more information see Data Only Container Madness.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With