Not able to start docker on Ubuntu 16.04.2 LTS (er

2019-05-10 11:16发布

问题:

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'.

回答1:

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



回答2:

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.