Linux changes the way Docker runs the root directory

  
                

Many Linux users did not allocate the /var partition when they installed the system. After installing Docker, it was found that its default location is in /var/lib/docker. So it caused Docker to run very slowly, so how to solve this problem? Let's take a look at the solution.

Solution:

First, reinstall the system, which is too humane, ignored. . . The next time you deploy the Docker host, you have to partition it.

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

Check the manual to find: -g, --graph=“/var/lib/docker” Set the Docker runtime root directory

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

The original image and container can not be found, because the path is 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, which are inconsistent in each operating system.

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

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

I am using CentOS 7, so Just change vim /etc/sysconfig/docker to

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

Then Service docker start The path to restart Docker is changed to /home/lib/docker.

The above is the solution. Space Docker storage location is too small, resulting in a slow way to run a Docker, users have encountered this problem, resolve it in this way.

Copyright © Windows knowledge All Rights Reserved