Table of Contents
Move Docker Directory
Docker directory is
/var should be a system directory, and most of the files in
/var are log files, security related files, etc.
Docker is a application, which contains huge container data, move
/var/lib/docker to data disk should be the good practice.
The are two methods I used to move
Change Docker config
/etc/docker/daemon.json file, add following entry.
This makes the Docker implementation become non-standard, but as some other settings in this file also need to be set as well, such as Docker log file size, etc., this can be a normal practise for those system not many administrators.
Create soft link
/var/lib/docker to another location using
mv command, then create a soft link
/var/lib/docker point to new location.
This can be a simple and clear way, because system administrator can easily find the location without pre-check docker configuration, especially if predefined commands are required to be provided to others.
For the first method, changing Docker configuration, although the non-standard configuration used, but Docker knows the location of data.
For the second method, adminstrator knows file location, but Docker doesn't know. So, if Docker likes to optimize the system, it might get wrong info.