Currently this blog is running on two Docker containers. One running the node.js Blog engine and another running the PostgreSQL database server. The data of both the Blog container and the database container is mapped onto the Host virtual machine.
One thing that I need to arrange is to create backup’s of the data of both containers. I want to perform this using Data Volume containers. Data Volume containers are special containers that are only responsible for hosting the data volumes and nothing else. These Data Volume containers are then linked to the the containers running the application.
Currently I have the following two containers running
The following command creates a new data volume container and links it to the Ghost container.
The command creates a new container and maps the volumes
--volumes-from from the ghost container. The container is started in the foreground and executes a shell
sh. It uses the busybox base container.
Inside the container we are able to list the volumes from the Ghost container, for example
Using the same approach we can directly backup the container using a tar file with the following command.
And the same can be done for the PostgreSQL container using the following command.
Both commands create a tar file inside your home directory that includes the data from both volumes of each container.
Restoring the data using a data only container can be done using the following command which creates a new container and extract the tar archive inside that container that mapped the volume from the Ghost container.
And the same can be done for the PostGreSQL container
This concludes the setup of this Blog using Docker. We are using two containers, one for running the Ghost blog engine and another for running the PostGreSQL engine. Both containers are linked together so that the Ghost container knows the ip address of the PostGreSQL database. Fig is used to make configuring and booting both containers more easy.
Finally, this post explains how data only containers can be used to backup the data of both containers.
Next, we will be looking at scaling the Blog ;-)