Software & AppsOperating SystemLinux

How To Upgrade Docker After the Aufs Storage-Driver is No Longer Supported on Ubuntu LTS

Ubuntu 18

The Docker community has moved away from the aufs storage driver and now supports the overlay2 driver. This article will guide you through the process of upgrading Docker after the aufs storage-driver is no longer supported on Ubuntu LTS.

Quick Answer

To upgrade Docker after the aufs storage-driver is no longer supported on Ubuntu LTS, you need to stop Docker, backup your data, configure Docker to use the overlay2 storage driver, and verify the change. It’s important to note that this process involves several steps and should be tested in a non-production environment before performing it on your live system.

Understanding Docker Storage Drivers

Docker uses storage drivers to manage the contents of the image layers and the writable container layer. Each storage driver handles the implementation differently, but all drivers use stackable image layers and the copy-on-write (CoW) strategy.

The aufs storage driver was the first to be used by Docker, but it is not included in the mainline Linux kernel. The Docker community has since moved to the overlay2 driver, which is supported by the mainline kernel and offers significant performance improvements.

Preparing for the Upgrade

Before you start the upgrade process, it’s crucial to verify whether any of your containers are using the aufs storage driver. You can do this by running the following command:

docker info

This command will display system-wide information about Docker. Look for the “Storage Driver” field. If it says “aufs”, you will need to follow the steps in this guide.

Steps to Upgrade Docker

1. Stop Docker

First, you need to stop Docker. You can do this by running the following command:

sudo systemctl stop docker

2. Backup Docker Data

Next, you need to copy the contents of /var/lib/docker to a temporary location. This step is important because it allows you to recover quickly if something goes wrong during the upgrade process. Run the following command to backup your Docker data:

sudo cp -au /var/lib/docker /var/lib/docker.bk

In this command, -a is for archive mode, -u is for update mode. Archive mode ensures that the original file permissions and timestamps are preserved, while update mode ensures that only newer files are copied.

3. Configure Docker to Use the overlay2 Storage Driver

Now, you need to configure Docker to use the overlay2 storage driver. To do this, edit the Docker daemon configuration file /etc/docker/daemon.json. If the file doesn’t exist, create it. Add the following contents to the file:

{
 "storage-driver": "overlay2" 
}

This JSON file tells Docker to use the overlay2 storage driver. Make sure the JSON syntax is correct, as Docker will not start if the daemon.json file contains badly-formed JSON.

4. Start Docker

After configuring Docker to use the overlay2 storage driver, you can start Docker by running the following command:

sudo systemctl start docker

5. Verify the Storage Driver

Finally, verify that Docker is now using the overlay2 storage driver. Run the following command and check the output:

docker info

Look for the “Storage Driver” and “Backing filesystem” fields. They should indicate that overlay2 is being used.

Post-Upgrade Steps

After completing these steps, you will need to recreate your containers and fetch all images again with the new storage driver in place. Note that mapped container data using “bind mounts” should be unaltered, but any local modifications within the Docker filesystem will be lost.

If you have moved the data directory to a different location using the data-root option in daemon.json, you will also need to remove both aufs directories: the one under the new data-root and the one under /var/lib/docker.

It’s worth mentioning that this issue is a known bug in the Ubuntu Docker packaging, and it has been marked as “won’t fix” based on the Ubuntu Docker packaging policy. If you prefer a more seamless upgrade experience, you may consider installing Docker from the official Docker repositories instead of using the docker.io package provided by Canonical.

Conclusion

Upgrading Docker after the aufs storage-driver is no longer supported on Ubuntu LTS involves several steps, including stopping Docker, backing up your data, configuring Docker to use the overlay2 storage driver, and verifying the change. It’s always recommended to backup your data and test the upgrade process in a non-production environment before performing it on your live system.

What is the main difference between the aufs and overlay2 storage drivers?

The aufs storage driver was the first to be used by Docker but is not included in the mainline Linux kernel. On the other hand, the overlay2 storage driver is supported by the mainline kernel and offers significant performance improvements.

How can I check if my containers are using the aufs storage driver?

You can check the storage driver being used by running the command docker info and looking for the "Storage Driver" field. If it says "aufs", you will need to follow the steps in this guide to upgrade Docker.

What happens if I don’t upgrade Docker after the aufs storage driver is no longer supported?

If you don’t upgrade Docker, you may encounter compatibility issues and potential performance problems. It’s recommended to upgrade Docker to ensure compatibility and take advantage of the improvements offered by the overlay2 storage driver.

Can I revert the upgrade process if something goes wrong?

Yes, you can revert the upgrade process by stopping Docker, restoring the backed-up data in /var/lib/docker, and configuring Docker to use the previous storage driver. However, it’s always recommended to backup your data and test the upgrade process in a non-production environment before performing it on your live system.

Are there any post-upgrade steps I need to take?

After upgrading Docker, you will need to recreate your containers and fetch all images again with the new storage driver in place. Note that any local modifications within the Docker filesystem will be lost, but mapped container data using "bind mounts" should be unaltered. If you have moved the data directory to a different location using the data-root option in daemon.json, you will also need to remove both aufs directories: the one under the new data-root and the one under /var/lib/docker.

Leave a Comment

Your email address will not be published. Required fields are marked *