6

Facing the below error while starting docker with systemctl:

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

Below is the output if I cat form start service:

● 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'.
Vaseem007
  • 2,401
  • 22
  • 20
  • Do you have "important" local content? Have you tried simply removing anything in "/var/lib/docker"? – dbalakirev Jul 14 '17 at 13:14
  • According to the message you didn't specify a storage driver in the ExecStart instruction in /lib/systemd/system/docker.service. https://docs.docker.com/engine/userguide/storagedriver/selectadriver/ you can specify with -s then run systemctl daemon-reload to assume the new service configurations then systemctl start docker.service – Miguel Marques Jul 14 '17 at 15:34
  • It was an issue with graphic driver "Error starting daemon: error initializing graphdriver" I was able to resolve the issue by using overlay2 as storage driver. Note: If you use OverlayFS, use the overlay2 driver rather than the overlay driver, because it is more efficient in terms of inode utilization. To use the new driver, you need version 4.0 or higher of the Linux kernel. https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/ – Vaseem007 Jul 15 '17 at 06:58

3 Answers3

19

I did some research and I found the answer. I was able to fix the issue by using the overlay2 as storage driver. I followed the below link for that: https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/

I took the followins steps to fix the issue:

  1. Stop Docker.

    sudo systemctl stop docker
    
  2. Copy the contents of /var/lib/docker to a temporary location.

    cp -au /var/lib/docker /var/lib/docker.bk
    
  3. Edit /etc/docker/daemon.json. If it doesn't exist yet: create it. Assuming that the file was empty, add the following contents:

    {
      "storage-driver": "overlay2"
    }
    
  4. Start Docker.

    sudo systemctl start docker
    
  5. Verify that the daemon is using the overlay/overlay2 storage driver.

    sudo docker info
    

After this I was able to run docker container on my "16.04.2 LTS (Xenial Xerus)"

sudo docker run -dit ubuntu

Docker CE

For Docker CE only some configurations are tested. Your operating system’s kernel may not support every storage driver. In general, the following configurations work on recent versions of the Linux distribution:

Linux distribution Supported storage drivers Docker CE on Ubuntu aufs, devicemapper, overlay2 (Ubuntu 14.04.4 or later, 16.04 or later), overlay, zfs

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

MadMike
  • 1,391
  • 1
  • 16
  • 38
Vaseem007
  • 2,401
  • 22
  • 20
  • 1
    Thanks. Adding { "storage-driver": "aufs"} to /etc/docker/daemon.json did the job for me on Ubuntu 14.04.5 LTS (kernel 4.4.0). When then doing 'dockerd --debug' I got to see lots of images being migrated. – NealeU Jul 05 '18 at 13:37
  • The `"overlay2"` config as per the post worked for me on Ubuntu 16.04 – thanks! – Jemus42 Aug 06 '19 at 13:52
0

I had installed Docker on my server which ran Debian Jessie. I removed Docker and upgraded my server to Debian Stretch. But the systemd configuration file /etc/systemd/system/docker.service.d/execWithDeviceMapper.conf was not removed. The file had the configuration: storage-engine: devicemapper. The devicemapper storage engine does not work well with Debian Stretch.

I deleted the systemd configuration folder /etc/systemd/system/docker.service.d. I used the command: apt-get install docker-ce docker-ce-cli containerd.io to install Docker without problems.

Nadir Latif
  • 3,690
  • 1
  • 15
  • 24
0

As described in a blog post by Rowanto it can help to delete the /var/lib/docker/aufs before restarting docker.

You might lose some data (e.g. images, containers), so please do it with care!

sudo rm -rf /var/lib/docker/aufs

After that restart docker:

sudo service docker start
mojoaxel
  • 1,440
  • 1
  • 14
  • 19