📖 Scenario: You are setting up Docker on a new server. To optimize performance and compatibility, you need to configure Docker's storage driver options.
🎯 Goal: Learn how to create a Docker daemon configuration file with specific storage driver options and verify the configuration.
📋 What You'll Learn
Create a Docker daemon configuration file with a storage driver option
Add a storage driver option to the configuration
Apply the configuration by restarting Docker
Verify the storage driver setting using a Docker command
💡 Why This Matters
🌍 Real World
Configuring Docker storage drivers is important for optimizing container performance and compatibility on different Linux systems.
💼 Career
DevOps engineers often configure Docker daemon settings to meet application and infrastructure requirements.
Progress0 / 4 steps
1
Create Docker daemon configuration file
Create a file called /etc/docker/daemon.json with the following JSON content exactly: {}
Docker
Hint
The Docker daemon configuration file uses JSON format. Start with empty braces {}.
2
Add storage driver option
Add the storage driver option "storage-driver": "overlay2" inside the /etc/docker/daemon.json file, so the file content is exactly {"storage-driver": "overlay2"}
Docker
Hint
Remember to keep the JSON format valid with curly braces and quotes.
3
Restart Docker to apply configuration
Write the command to restart the Docker service using sudo systemctl restart docker to apply the new storage driver configuration.
Docker
Hint
Use sudo systemctl restart docker to restart the Docker daemon.
4
Verify Docker storage driver
Write the command docker info --format '{{.Driver}}' to display the current Docker storage driver in use.
Docker
Hint
The command docker info --format '{{.Driver}}' shows the active storage driver.
Practice
(1/5)
1. What is the main purpose of a Docker storage driver?
easy
A. To manage how Docker stores container data on disk
B. To control network settings for containers
C. To schedule container start times
D. To monitor container CPU usage
Solution
Step 1: Understand Docker storage drivers
Storage drivers define how Docker saves and manages container data on the host disk.
Step 2: Identify the correct function
Among the options, only managing container data storage matches the role of storage drivers.
Final Answer:
To manage how Docker stores container data on disk -> Option A
Quick Check:
Storage driver = manages container data storage [OK]
Hint: Storage drivers handle container data storage, not networking or CPU [OK]
2. Which of the following is the correct syntax to specify the storage driver when starting the Docker daemon manually?
easy
A. docker run --storage-driver=overlay2
B. dockerd --storage-driver=overlay2
C. dockerd -storage driver overlay2
D. docker daemon --storage=overlay2
Solution
Step 1: Recall Docker daemon start syntax
The Docker daemon is started with the command 'dockerd' and options use double dashes with hyphens.
Step 2: Match correct option format
dockerd --storage-driver=overlay2 uses 'dockerd --storage-driver=overlay2' which is the correct syntax to set the storage driver.
Final Answer:
dockerd --storage-driver=overlay2 -> Option B
Quick Check:
Daemon start uses 'dockerd --storage-driver' [OK]
Hint: Use 'dockerd --storage-driver=drivername' to set storage driver [OK]
Common Mistakes:
Using 'docker run' instead of 'dockerd' to set storage driver
Incorrect flag syntax like '-storage driver'
Using 'docker daemon' which is deprecated
3. Given the Docker daemon started with dockerd --storage-driver=aufs, what will be the output of docker info | grep 'Storage Driver'?
medium
A. Storage Driver: aufs
B. Storage Driver: btrfs
C. Storage Driver: devicemapper
D. Storage Driver: overlay2
Solution
Step 1: Understand the command effect
The command 'docker info | grep "Storage Driver"' filters Docker info output to show the storage driver in use.
Step 2: Match the storage driver set at daemon start
Since the daemon was started with '--storage-driver=aufs', the output will show 'Storage Driver: aufs'.
Final Answer:
Storage Driver: aufs -> Option A
Quick Check:
Set driver = output driver [OK]
Hint: Output matches the driver set at daemon start [OK]
Common Mistakes:
Assuming default driver instead of the one set
Confusing output with other storage drivers
Not using correct grep syntax
4. You tried to start Docker with dockerd --storage-driver=overlay3 but it failed. What is the most likely reason?
medium
A. The storage driver option requires a space, not an equals sign
B. You need to use 'docker run' instead of 'dockerd'
C. Docker does not support storage drivers on Linux
D. overlay3 is not a valid Docker storage driver
Solution
Step 1: Verify valid storage drivers
Docker supports drivers like overlay2, aufs, devicemapper, but 'overlay3' is not a valid driver.
Step 2: Check command usage
The command 'dockerd --storage-driver=overlay3' is correct syntax, but the driver name is invalid, causing failure.
Final Answer:
overlay3 is not a valid Docker storage driver -> Option D
Quick Check:
Invalid driver name causes failure [OK]
Hint: Check driver name spelling and validity before starting daemon [OK]
Common Mistakes:
Using invalid or unsupported driver names
Confusing 'dockerd' with 'docker run'
Incorrect flag syntax
5. You want to optimize Docker performance on a system with an ext4 filesystem. Which storage driver option should you choose in the Docker daemon configuration file for best compatibility and performance?
hard
A. aufs
B. devicemapper
C. overlay2
D. btrfs
Solution
Step 1: Identify filesystem compatibility
Overlay2 is recommended for ext4 filesystems because it is stable and performs well on ext4.
Step 2: Compare other drivers
Devicemapper is older and less efficient; aufs is deprecated on many systems; btrfs requires btrfs filesystem, not ext4.
Final Answer:
overlay2 -> Option C
Quick Check:
ext4 + overlay2 = best performance [OK]
Hint: Use overlay2 for ext4 filesystem for best Docker performance [OK]
Common Mistakes:
Choosing btrfs on ext4 filesystem
Using devicemapper despite better options
Assuming aufs is always best
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.