Difficulty: Beginner
Estimated Time: 10 minutes

There are two ways of approaching stateful Containers, that is containers are store and persistent data for future use. This could be the container creating and storing data, for example, a database. Alternatively, it could be data requiring additional for instance the configuration or SSL certifications. This approach can also be used to backup data or debug containers.

One approach we've discussed is using the -v <host-dir>:<container-dir> option to map directories. The other approach is to use Data Containers. This scenario will introduce the advantages of using Data Containers.

This scenario has explained how to use Data Containers. Data Containers are a great way of managing configuration data which can be used by other containers. The volumes-from property allows us to gain access to other containers volumes which we can utilise for debugging or backup purposes.

Don’t stop now! The next scenario will take about 20 minutes to complete. You can pause and come back at any time.

Data Containers

Step 1 of 4

Step 1 - Create Container

Data Containers are containers which sole responsibility to be a place to store/manage data.

Like other containers they are managed by the host system. However, they don't run 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. We use busybox as the base as it's small and lightweight in case we want to explore and move the container to another host.

When creating the container, we also provide a -v option to define where other containers will be reading/saving data.

Task

Create a Data Container for storing configuration files using docker create -v /config --name dataContainer busybox