Get the App
SLTechnology News&Howtos  ›  Development  › 

How to modify the storage location of Docker local image and container in linux

Shulou Source: shulou.com Published: 2022-06-02 01:05:34 10月05日 Update

This article mainly explains "how to modify the storage location of Docker local images and containers in linux". The explanation in this article is simple and clear and easy to learn and understand. please follow the editor's ideas to study and learn "how to modify the storage location of Docker local images and containers in linux".

Method: soft link

By default, the location of Docker is: / var/lib/docker

You can view the location with the following command:

[root@omisclass ~] # docker info | grep "Docker Root Dir" WARNING: You're not using the default seccomp profileDocker Root Dir: / var/lib/docker

Of course, the most direct way to solve this problem is to mount the partition to this directory, but there are other things on my data disk, which must be difficult to manage, so change the storage path of the image and container to achieve the goal.

This method will be implemented through soft connections.

First stop the Docker service:

Systemctl stop docker.service

Then move the entire / var/lib/docker directory to the destination path:

Mv / var/lib/docker / root/data/dockerln-s / root/data/docker / var/lib/dockersystemctl restart docker

At this time, when you start Docker, you find that the storage directory is still / var/lib/docker, but it is actually stored on the data disk, and you can see the capacity change on the data disk.

Thank you for reading, the above is the content of "how to modify the storage location of Docker local image and container in linux". After the study of this article, I believe you have a deeper understanding of how to modify the storage location of Docker local image and container in linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Location storage container mirror data method directory learning content situation purpose path problem bad thing can be passed command actual actually capacity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi vpn MariaDB Docker