Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most appropriate container for a data only container?

Tags:

docker

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?

like image 451
Ashley Aitken Avatar asked Sep 15 '14 10:09

Ashley Aitken


People also ask

What is 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.

What is Docker data container?

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.

Can we store data in Docker container?

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.

What is container data volume?

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.


1 Answers

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:

  • It will take up less space as you already have the image cached.
  • The image gets a chance to seed the volume with data e.g. default files.
  • The permissions and owner will be correct.

For more information see Data Only Container Madness.

like image 172
Adrian Mouat Avatar answered Sep 22 '22 17:09

Adrian Mouat