How to modify docker's default storage directory

Release: 2020-04-01 13:27:09
Original
4590 people have browsed it

How to modify docker's default storage directory

By default, the default storage path of the docker image is /var/lib/docker, which is equivalent to directly mounting the system directory. Generally, when building a system, this area is It won't be too big, so if you use docker to develop applications for a long time, you need to change the default path to the required path or external storage.

Let’s take a look at how to modify the default storage directory of docker:

You can see that the default storage directory of docker is through the docker info command:

Docker Root Dir: /var/lib/docker
Copy after login

In docker The default storage directory can be modified in the configuration file of systemd's docker.service.

If you don’t know where the configuration file is, you can use the systemd command to view it:

# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
Copy after login

Modify the docker.service file.

# vim /usr/lib/systemd/system/docker.service
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (注释原先的)
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph=/data/docker(新增的)
Copy after login

Restart:

systemctl daemon-reload
systemctl restart docker
Copy after login

For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.

The above is the detailed content of How to modify docker's default storage directory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!