linux - 无法在 Ubuntu 16.04.2 LTS 上启动 docker(初始化 graphdriver 时出错)

标签 linux docker ubuntu-16.04

在使用 systemctl 启动 docker 时遇到以下错误:

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

如果我从启动服务开始,下面是输出:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2017-07-14 18:23:13 IST; 2min 4s ago
     Docs: https://docs.docker.com
  Process: 6325 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=1/FAILURE)
 Main PID: 6325 (code=exited, status=1/FAILURE)

Jul 14 18:23:12 iconlap02 systemd[1]: Starting Docker Application Container Engine...
Jul 14 18:23:12 iconlap02 dockerd[6325]: time="2017-07-14T18:23:12.415162784+05:30" level=info msg="libcontainerd: new containerd process, pid: 6333"
Jul 14 18:23:13 iconlap02 dockerd[6325]: Error starting daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: aufs, overlay; Please cleanup or explicitly choose storage driver (-s <DRIVER>)
Jul 14 18:23:13 iconlap02 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 18:23:13 iconlap02 systemd[1]: Failed to start Docker Application Container Engine.
Jul 14 18:23:13 iconlap02 systemd[1]: docker.service: Unit entered failed state.
Jul 14 18:23:13 iconlap02 systemd[1]: docker.service: Failed with result 'exit-code'.

最佳答案

我做了一些研究并找到了答案。我能够通过使用 overlay2 作为存储驱动程序来解决这个问题。为此,我点击了以下链接:https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/

我采取了以下步骤来解决这个问题:

  1. 停止 Docker。

    sudo systemctl stop docker
    
  2. /var/lib/docker 的内容复制到一个临时位置。

    cp -au /var/lib/docker /var/lib/docker.bk
    
  3. 编辑 /etc/docker/daemon.json。如果它还不存在:创建它。假设文件为空,添加以下内容:

    {
      "storage-driver": "overlay2"
    }
    
  4. 启动 Docker。

    sudo systemctl start docker
    
  5. 验证守护进程正在使用 overlay/overlay2 存储驱动程序。

    sudo docker info
    

在此之后,我能够在我的“16.04.2 LTS (Xenial Xerus)”上运行 docker 容器

sudo docker run -dit ubuntu

Docker CE

对于 Docker CE,仅测试了部分配置。您的操作系统内核可能不支持所有存储驱动程序。通常,以下配置适用于最新版本的 Linux 发行版:

Linux 发行版支持的存储驱动 Ubuntu 上的 Docker CE aufs、devicemapper、overlay2(Ubuntu 14.04.4 或更高版本、16.04 或更高版本)、overlay、zfs

https://github.com/moby/moby/issues/24023

关于linux - 无法在 Ubuntu 16.04.2 LTS 上启动 docker(初始化 graphdriver 时出错),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45103803/

相关文章:

docker - 挂载卷目录时docker中的随机错误。

mongodb - 用于编辑 MongoDB 配置文件的 Bash 脚本

mysql - 将mysql从4.1.22升级到5.0

docker - docker堆栈部署失败

docker - 如何整合AWS+ELB+AutoScale+Docker+Spring Cloud

ubuntu - 使用 ImageMagick 从文本生成图像?

ubuntu-16.04 - Ubuntu 16.04 LTS 运行低图形模式

regex - 我在 Linux 中使用带有正则表达式的 sed 但没有得到预期的答案

linux - 从命令行参数显示特定目录的内容

linux - 通过传递路径打开文件在 Linux 上有效,但在 Windows 上无效