Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#14 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
docker, linux

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Python
星标
5
派生
2
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

davideuler/programming-tips 的其他 Issue

查看 davideuler/programming-tips 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。