Oracle Sean

View Original

Docker Service Startup Failure When Using A Custom Docker Directory on Linux

On Linux, you can change where Docker persists its resources from /var/lib/docker to a different directory. This directory contains all of your images, container layers, and volumes, and if your boot volume is small, Docker can quickly dominate the disk.

Most references I’ve seen tell you to update the location by editing the /lib/systemd/system/docker.service configuration file and change the following line:

See this content in the original post

…by adding an entry with the -g or --graph flag:

See this content in the original post

Indeed, that works for versions before 17.05. However, in versions 17.05 and later, the -g and --graph options are deprecated. After updating Docker and restarting the service or host, you’ll see this error:

See this content in the original post

Checking the status of the service shows:

See this content in the original post

Or:

See this content in the original post

Or:

See this content in the original post

The status output will lead you to the cause. Check journalctl -xe and within a few lines you’ll see a message indicating that use of the —-graph flag is deprecated and to instead use —-data-root:

See this content in the original post

After changing the entry in /lib/systemd/system/docker.service to use the proper flag, Docker once again recognizes the non-default directory and starts normally.

See this content in the original post