Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Change Docker root directory /var/lib/docker to another location

Đang mở
#14 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
45/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
docker, linux
Lĩnh vực
devops, infrastructure

Hướng nghiên cứu

Review the repository's existing organization for programming tips, then verify the Docker commands and storage-driver references in the issue against the linked Docker documentation. Done means the relocation instructions are added in the project's established format and clearly cover stopping, moving, reconfiguring, restarting, and filesystem limitations.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

From:
https://linuxconfig.org/how-to-move-docker-s-default-var-lib-docker-to-another-directory-on-ubuntu-debian-linux

By default, Docker stores most of its data inside the /var/lib/docker directory on Linux systems. There may come a time when you want to move this storage space to a new location. For example, the most obvious reason might be that you’re running out of disk space.

1.How to edit systemd to accommodate new Docker location? stop the service, update config, and restart

$sudo systemctl stop docker.service
$sudo systemctl stop docker.socket

$sudo vim /lib/systemd/system/docker.service

The line we need to edit looks like this:

ExecStart=/usr/bin/dockerd -H fd://

Edit the line by putting a -g and the new desired location of your Docker directory. When you’re done making this change, you can save and exit the file.

# for old docker 
ExecStart=/usr/bin/dockerd -g /mnt/data/docker/ -H fd://

# for newer versions
ExecStart=/usr/bin/dockerd --data-root /mnt/data/docker/ -H fd://  

2.How to move your Docker installation to a new location?

sudo mkdir -p /data/docker
sudo rsync -aqxP /var/lib/docker/ /data/docker

start docker:

$ sudo systemctl daemon-reload
$ sudo systemctl start docker

Note, if you get error of:

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.

It may caused by File System not supported by docker. For my case, when I try to save docker data to NAS driver, it failed. For local driver, it works.
The docker data should be stored on a supported backing filesystem as mentioned here:
https://docs.docker.com/engine/storage/drivers/select-storage-driver/#supported-backing-filesystems

Ngôn ngữ chính
Python
Star
5
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của davideuler/programming-tips

Tất cả issue của davideuler/programming-tips

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.