For this discussion, we will configure overlay2 as the storage driver. Although it is configured by default, and you can skip the steps if you are following this book, it is worth a read in case you want to change it to something else.
First, let’s list the existing storage driver:
$ docker info | grep ‘Storage Driver’
Storage Driver: overlay2
We can see that the existing storage driver is already overlay2. Let’s learn how to change it to devicemapper if we had to.
Edit the /etc/docker/daemon.json file using an editor of your choice. If you’re using vim, run the following command:
$ sudo vim /etc/docker/daemon.json
Add the storage-driver entry to the daemon.json configuration file:
{
“storage-driver”: “devicemapper”
}
Then, restart the Docker service:
$ sudo systemctl restart docker
Check the status of the Docker service:
$ sudo systemctl status docker
Now, rerun docker info to see what we get:
$ docker info | grep ‘Storage Driver’
Storage Driver: devicemapper
WARNING: The devicemapper storage-driver is deprecated, and will be removed in a future release.
Refer to the documentation for more information: https://docs.docker.com/go/ storage-driver/
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
Use `–storage-opt dm.thinpooldev` to specify a custom block storage device.
Here, we can see the devicemapper storage driver. We can also see several warnings with it that say that the devicemapper storage driver is deprecated and will be removed in a future version.
Therefore, we should stick with the defaults unless we have a particular requirement.
So, let’s roll back our changes and set the storage driver to overlay2 again:
$ sudo vim /etc/docker/daemon.json
Modify the storage-driver entry in the daemon.json configuration file to overlay2:
{
“storage-driver”: “overlay2”
}
Then, restart the Docker service and check its status:
$ sudo systemctl restart docker
$ sudo systemctl status docker
If you rerun docker info, you will see the storage driver as overlay2, and all the warnings will disappear:
$ docker info | grep ‘Storage Driver’
Storage Driver: overlay2
Tip
Changing the storage driver will wipe out existing containers from the disk, so exercise caution when you do so and take appropriate downtimes if you’re doing this in production. You will also need to pull images again since local images will fail to exist.
Now that we have installed Docker on our machine and configured the right storage driver, it’s time to run our first container.