Home  >  Article  >  Operation and Maintenance  >  How to modify docker's default storage directory

How to modify docker's default storage directory

尚
Original
2020-04-01 13:27:094628browse

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

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.

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(新增的)

Restart:

systemctl daemon-reload
systemctl restart docker

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!

Statement:
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