跳到主要内容

Docker 故障排除

信息

This page offers troubleshooting guidance specifically for Docker containers on Unraid, managed by the Unraid team. For advanced troubleshooting, in-depth technical details, or topics beyond the Unraid-specific implementation, please refer to the official Docker documentation.

Docker makes it easy to run a variety of applications on your Unraid server, but issues can arise, such as containers not starting, corrupted Docker image files, or network problems. This page addresses some common issues related to Docker on Unraid and offers best practices for effectively resolving them.


重新创建 Docker 映像文件

A corrupted Docker image file (docker.img) is a common issue, often caused by the cache pool running out of space or an unclean shutdown. Luckily, a well-configured container stores all variable data outside the image file (usually in the appdata share), so you can safely recreate the image without losing your application settings or data.

要重新创建 Docker 映像文件:

  1. 转到 WebGUI 中的 Settings → Docker
  2. Enable Docker(启用 Docker) 设置为 No(否),然后单击 Apply(应用) 停止 Docker 服务。
  3. 选择删除Docker vdisk文件的选项,然后点击应用。如果需要,还可以手动删除文件。
  4. 确认新Docker vdisk文件的位置和文件名。此设置包括文件夹路径和文件名。
  5. 设置新映像文件的所需大小。默认大小通常足以满足大多数用户的需求。
  6. Set Enable Docker to Yes and click Apply. Unraid will create and format a new docker.img file using BTRFS.

现在您可以使用其保存的设置重新安装容器。


重新安装 Docker 应用程序

Unraid automatically saves a template for each installed container on your flash drive. These templates store your configuration, making it easy to restore containers after recreating the Docker image file.

要重新安装您的容器:

  1. 转到%%WebGUI|WebGUI%%的应用选项卡。
  2. 打开 Previous Apps(以前的应用) 部分。
  3. 选择要重新安装的容器。
  4. Proceed with the installation. Unraid will re-download each container and apply your previous settings automatically.
important

如果所有可变数据映射在 Docker 映像文件之外(例如,在 appdata 共享中),这个过程会将您的容器恢复到先前状态。

提示

如果容器在重新安装后无法启动,请从 Docker 选项卡的上下文菜单中检查其日志,以查找错误消息和故障排除提示。

备注

在恢复你的容器后,验证所有映射的主机路径是否存在并具有正确的权限。错误的映射或权限是启动问题的常见原因。


恢复 Docker 自定义网络

如果删除Docker映像文件,自定义Docker网络将不会持久化。在移除映像之前,通过打开终端并运行以下命令记录你的自定义网络名称:

docker network ls

记下您创建的任何网络的名称(不包括默认的 bridgehostnone 网络)。

要恢复自定义网络:

  1. 在重新创建 Docker 映像文件后,使用以下命令重建每个自定义网络:

    docker network create <network-name>

    <network-name> 替换为您先前记录的准确名称。

  2. 根据需要更新您的容器以使用恢复的网络。

备注

如果您的设置需要,您可以在 Settings → Docker 中通过将 主机访问自定义网络 设置为 启用 来启用对自定义网络的主机访问。

提示

如果在恢复后容器无法按预期通信,请检查您的 Docker 网络设置是否存在冲突或连接问题。