If you are looking for software to use, go to Huajun Software Park! software release
Location: front pageTutorial strategyTutorialComputer software tutorials Linux changes D...

How to change the Docker running root directory in Linux

Author: Shaobing Date: 2017-05-23

The following is a method to solve the problem that the space where Docker is stored is too small, causing Docker to run slowly. Users who have encountered this problem can use this method to solve it.

How to change the Docker running root directory in Linux

Solution:

The first is to reinstall the system, which is too inhumane and should be ignored. . . Next time you deploy the Docker host, you must partition it carefully.

The second is to change the default storage path of Docker.

I checked the manual and found: -g, --graph="/var/lib/docker" sets the Docker runtime root directory

Use the --graph parameter: docker --graph=/opt/docker -d, the /opt/docker directory (0700) will be automatically generated, and docker related files will be created in this directory

The original image and container can no longer be found because the path has been changed (the original image is in /var/lib/docker/devicemapper/devicemapper/{data, metadata})

Docker's configuration file can set most of the background process parameters, but the storage locations are inconsistent in various operating systems.

The location in ubuntu is: /etc/default/docker

The location in centos is: /etc/sysconfig/docker

I'm using CentOS 7, so just change vim /etc/sysconfig/docker to

OPTIONS=--graph=“/home/lib/docker” --selinux-enabled -H fd://

Then use service docker start to restart Docker and the path will be changed to /home/lib/docker

 

Related articles