0
0
Dockerdevops~5 mins

Storage driver options in Docker - Commands & Configuration

Choose your learning style9 modes available
Introduction
Docker uses storage drivers to manage how data is stored and shared between containers and the host system. Choosing the right storage driver helps keep your containers fast and your disk space organized.
When you want to improve container performance by selecting a storage method optimized for your system.
When you need to troubleshoot issues related to container file storage or disk usage.
When setting up Docker on a new server and want to configure storage for best compatibility.
When running multiple containers that share data and you want to control how that data is stored.
When upgrading Docker and want to switch to a newer storage driver for better features.
Commands
This command shows the current storage driver Docker is using on your system.
Terminal
docker info --format '{{.Driver}}'
Expected OutputExpected
overlay2
Starts the Docker daemon using the overlay2 storage driver, which is recommended for most modern Linux systems for better performance and stability.
Terminal
dockerd --storage-driver=overlay2
Expected OutputExpected
INFO[0000] Starting up INFO[0000] Using storage driver overlay2
--storage-driver - Specifies which storage driver Docker should use
Runs a temporary Alpine Linux container to test that Docker is working with the chosen storage driver.
Terminal
docker run --rm -it alpine sh
Expected OutputExpected
/ #
--rm - Automatically removes the container after it exits
-it - Runs the container interactively with a terminal
Key Concept

If you remember nothing else from this pattern, remember: the storage driver controls how Docker saves and shares container data on your system.

Common Mistakes
Trying to change the storage driver without restarting the Docker daemon.
Docker needs to restart to apply a new storage driver; otherwise, it keeps using the old one.
Stop Docker, change the storage driver setting, then start Docker again.
Using a storage driver not supported by the host operating system.
Unsupported drivers can cause Docker to fail or behave unpredictably.
Check Docker documentation for supported storage drivers on your OS before changing.
Ignoring the current storage driver and trying to troubleshoot storage issues blindly.
Different drivers have different behaviors; knowing the driver helps diagnose problems correctly.
Always check the current storage driver with 'docker info' before troubleshooting.
Summary
Use 'docker info --format '{{.Driver}}'' to check which storage driver Docker is using.
Set the storage driver by starting the Docker daemon with the '--storage-driver' flag.
Test your Docker setup by running a simple container to ensure storage works correctly.