60

I've been trying to use Docker (1.10) on Ubuntu 16.04 but installation fails because Docker Service doesn't start. I've already tried to install docker by docker.io, docker-engine apt packages and curl -sSL https://get.docker.com/ | sh but it doesn't work.

My Host info is:

Linux Xenial 4.5.3-040503-generic #201605041831 SMP Wed May 4 22:33:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Here is systemctl status docker.service:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since sáb 2016-05-14 15:17:31 CEST; 12min ago
     Docs: https://docs.docker.com
  Process: 22479 ExecStart=/usr/bin/docker daemon -H fd:// (code=exited, status=1/FAILURE)
 Main PID: 22479 (code=exited, status=1/FAILURE)

may 14 15:17:30 Xenial docker[22479]: time="2016-05-14T15:17:30.103601523+02:00" level=info msg="New containerd process, pid: 22485\n"
may 14 15:17:31 Xenial docker[22479]: time="2016-05-14T15:17:31.149064723+02:00" level=error msg="devmapper: Unable to delete device: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool"
may 14 15:17:31 Xenial docker[22479]: time="2016-05-14T15:17:31.149127439+02:00" level=warning msg="devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section."
may 14 15:17:31 Xenial docker[22479]: time="2016-05-14T15:17:31.153010028+02:00" level=error msg="[graphdriver] prior storage driver \"devicemapper\" failed: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool"
may 14 15:17:31 Xenial docker[22479]: time="2016-05-14T15:17:31.153130839+02:00" level=fatal msg="Error starting daemon: error initializing graphdriver: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool"
may 14 15:17:31 Xenial systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
may 14 15:17:31 Xenial docker[22479]: time="2016-05-14T15:17:31+02:00" level=info msg="stopping containerd after receiving terminated"
may 14 15:17:31 Xenial systemd[1]: Failed to start Docker Application Container Engine.
may 14 15:17:31 Xenial systemd[1]: docker.service: Unit entered failed state.
may 14 15:17:31 Xenial systemd[1]: docker.service: Failed with result 'exit-code'.

Here is sudo docker daemon -D

DEBU[0000] docker group found. gid: 999                 
DEBU[0000] Listener created for HTTP on unix (/var/run/docker.sock) 
INFO[0000] previous instance of containerd still alive (23050) 
DEBU[0000] containerd connection state change: CONNECTING 
DEBU[0000] Using default logging driver json-file       
DEBU[0000] Golang's threads limit set to 55980          
DEBU[0000] received past containerd event: &types.Event{Type:"live", Id:"", Status:0x0, Pid:"", Timestamp:0x57372cae} 
DEBU[0000] containerd connection state change: READY    
DEBU[0000] devicemapper: driver version is 4.34.0       
DEBU[0000] devmapper: Generated prefix: docker-8:6-2101297 
DEBU[0000] devmapper: Checking for existence of the pool docker-8:6-2101297-pool 
DEBU[0000] devmapper: poolDataMajMin=7:0 poolMetaMajMin=7:1

DEBU[0000] devmapper: Major:Minor for device: /dev/loop0 is:7:0 
DEBU[0000] devmapper: Major:Minor for device: /dev/loop1 is:7:1 
DEBU[0000] devmapper: loadDeviceFilesOnStart()          
DEBU[0000] devmapper: Skipping file /var/lib/docker/devicemapper/metadata/transaction-metadata 
DEBU[0000] devmapper: loadDeviceFilesOnStart() END      
DEBU[0000] devmapper: constructDeviceIDMap()            
DEBU[0000] devmapper: constructDeviceIDMap() END        
DEBU[0000] devmapper: Rolling back open transaction: TransactionID=1 hash= device_id=1 
ERRO[0000] devmapper: Unable to delete device: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool 
WARN[0000] devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section. 
DEBU[0000] devmapper: Initializing base device-mapper thin volume 
DEBU[0000] devicemapper: CreateDevice(poolName=/dev/mapper/docker-8:6-2101297-pool, deviceID=1) 
DEBU[0000] devmapper: Error creating device: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool 
DEBU[0000] devmapper: Error device setupBaseImage: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool 
ERRO[0000] [graphdriver] prior storage driver "devicemapper" failed: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool 
DEBU[0000] Cleaning up old mountid : start.             
FATA[0000] Error starting daemon: error initializing graphdriver: devicemapper: Can't set task name /dev/mapper/docker-8:6-2101297-pool

Here is ./check-config.sh output:

warning: /proc/config.gz does not exist, searching other paths for kernel config ...
info: reading kernel config from /boot/config-4.5.3-040503-generic ...

Generally Necessary:
- cgroup hierarchy: properly mounted [/sys/fs/cgroup]
- apparmor: enabled and tools installed
- CONFIG_NAMESPACES: enabled
- CONFIG_NET_NS: enabled
- CONFIG_PID_NS: enabled
- CONFIG_IPC_NS: enabled
- CONFIG_UTS_NS: enabled
- CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled
- CONFIG_CGROUPS: enabled
- CONFIG_CGROUP_CPUACCT: enabled
- CONFIG_CGROUP_DEVICE: enabled
- CONFIG_CGROUP_FREEZER: enabled
- CONFIG_CGROUP_SCHED: enabled
- CONFIG_CPUSETS: enabled
- CONFIG_MEMCG: enabled
- CONFIG_KEYS: enabled
- CONFIG_MACVLAN: enabled (as module)
- CONFIG_VETH: enabled (as module)
- CONFIG_BRIDGE: enabled (as module)
- CONFIG_BRIDGE_NETFILTER: enabled (as module)
- CONFIG_NF_NAT_IPV4: enabled (as module)
- CONFIG_IP_NF_FILTER: enabled (as module)
- CONFIG_IP_NF_TARGET_MASQUERADE: enabled (as module)
- CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: enabled (as module)
- CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled (as module)
- CONFIG_NF_NAT: enabled (as module)
- CONFIG_NF_NAT_NEEDED: enabled
- CONFIG_POSIX_MQUEUE: enabled

Optional Features:
- CONFIG_USER_NS: enabled
- CONFIG_SECCOMP: enabled
- CONFIG_CGROUP_PIDS: enabled
- CONFIG_MEMCG_KMEM: missing
- CONFIG_MEMCG_SWAP: enabled
- CONFIG_MEMCG_SWAP_ENABLED: missing
    (note that cgroup swap accounting is not enabled in your kernel config, you can enable it by setting boot option "swapaccount=1")
- CONFIG_BLK_CGROUP: enabled
- CONFIG_BLK_DEV_THROTTLING: enabled
- CONFIG_IOSCHED_CFQ: enabled
- CONFIG_CFQ_GROUP_IOSCHED: enabled
- CONFIG_CGROUP_PERF: enabled
- CONFIG_CGROUP_HUGETLB: enabled
- CONFIG_NET_CLS_CGROUP: enabled (as module)
- CONFIG_CGROUP_NET_PRIO: enabled
- CONFIG_CFS_BANDWIDTH: enabled
- CONFIG_FAIR_GROUP_SCHED: enabled
- CONFIG_RT_GROUP_SCHED: missing
- CONFIG_EXT3_FS: missing
- CONFIG_EXT3_FS_XATTR: missing
- CONFIG_EXT3_FS_POSIX_ACL: missing
- CONFIG_EXT3_FS_SECURITY: missing
    (enable these ext3 configs if you are using ext3 as backing filesystem)
- CONFIG_EXT4_FS: enabled
- CONFIG_EXT4_FS_POSIX_ACL: enabled
- CONFIG_EXT4_FS_SECURITY: enabled
- Network Drivers:
  - "overlay":
    - CONFIG_VXLAN: enabled (as module)
- Storage Drivers:
  - "aufs":
    - CONFIG_AUFS_FS: missing
  - "btrfs":
    - CONFIG_BTRFS_FS: enabled (as module)
  - "devicemapper":
    - CONFIG_BLK_DEV_DM: enabled
    - CONFIG_DM_THIN_PROVISIONING: enabled (as module)
  - "overlay":
    - CONFIG_OVERLAY_FS: enabled (as module)
  - "zfs":
    - /dev/zfs: missing
    - zfs command: missing
    - zpool command: missing

If someone could please help me I would be very thankful

Salva Corts
  • 862
  • 1
  • 7
  • 12

11 Answers11

106

Update

It seems that in newer versions of docker and Ubuntu the unit file for docker is simply masked (pointing to /dev/null).
You can verify it by running the following commands in the terminal:

sudo file /lib/systemd/system/docker.service
sudo file /lib/systemd/system/docker.socket

You should see that the unit file symlinks to /dev/null.
In this case, all you have to do is follow S34N's suggestion, and run:

sudo systemctl unmask docker.service
sudo systemctl unmask docker.socket
sudo systemctl start docker.service
sudo systemctl status docker

I'll also keep the original post, that answers the error log stating that the storage driver should be replaced:

Original Post

I had the same problem, and I tried fixing it with Salva Cort's suggestion, but printing /etc/default/docker says:

# THIS FILE DOES NOT APPLY TO SYSTEMD

So here's a permanent fix that works for systemd (Ubuntu 15.04 and higher):

  1. create a new file /etc/systemd/system/docker.service.d/overlay.conf with the following content:

    [Service]
    ExecStart=
    ExecStart=/usr/bin/docker daemon -H fd:// -s overlay
    
  2. flush changes by executing:

    sudo systemctl daemon-reload
    
  3. verify that the configuration has been loaded:

    systemctl show --property=ExecStart docker
    
  4. restart docker:

    sudo systemctl restart docker
    
dvir
  • 2,546
  • 2
  • 18
  • 15
  • 1
    Also works for [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) if you change all the `docker` to `nvidia-docker` – Laurenz Aug 09 '16 at 18:30
  • 3
    I had to add the whole command line from the corresponding line in `/etc/systemd/system/docker.service` to get this to work. Step 1 as given just overwrote all the command line arguments, losing a lot of arguments in my case. – rep Aug 23 '16 at 16:22
  • 2
    This answer (not the linked answer) does not seem to work any more, at least on Ubuntu 16.04, Docker version 17.12.1-ce. There is an error preventing the service from starting which contains the messages "ExecStart=/usr/bin/docker daemon -H fd:// -s overlay (code=exited, status=125)" and "unknown shorthand flag: 's' in -s" So apparently the -s flag is no longer supported. – Tony Feb 28 '18 at 19:23
  • 3
    it even works if you simply edit/create a file at `/etc/docker/daemon.json` and add lines **{ "storage-driver": "overlay2" }** then `sudo systemctl restart docker.service` – Naitik Shah Apr 10 '18 at 07:20
  • The problem here isn’t that newer versions mask docker.service on installation; the problem is that older versions mask it on uninstallation. So this will only apply to you if you installed an older version, removed it, and then installed a newer version. I just filed [LP #1844894](https://bugs.launchpad.net/ubuntu/+source/docker.io/+bug/1844894) with details. – Anders Kaseorg Sep 21 '19 at 22:30
  • 1
    Those systemctl commands were exactly what I needed after upgrading to 20.04 this morning – MattBoothDev Apr 23 '20 at 13:57
44

The following unmasking commands worked for me (Ubuntu 18). Hope it helps someone out there... :-)

sudo systemctl unmask docker.service
sudo systemctl unmask docker.socket
sudo systemctl start docker.service
S34N
  • 7,469
  • 6
  • 34
  • 43
13

I had the same problem after upgrade docker from 17.05-ce to 17.06-ce via docker-machine

  1. Update /etc/systemd/system/docker.service.d/10-machine.conf

    replace

    `docker daemon` => `dockerd`
    

    example from

    [Service]
    ExecStart=
    ExecStart=/usr/bin/docker deamon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic
    Environment=
    

    to

    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic
    Environment=
    
  2. flush changes by executing:

    sudo systemctl daemon-reload
    
  3. restart docker:

    sudo systemctl restart docker
    
evandrix
  • 6,041
  • 4
  • 27
  • 38
Roman Rhrn Nesterov
  • 3,538
  • 1
  • 28
  • 16
  • This solution worked for me when trying to run docker-machine against a newly provisioned digitalocean droplet. – cwash Aug 14 '17 at 02:55
9

Well, finally I fixed it

Everything you have to do is to load a different storage-driver in my case I will use overlay:

  1. Disable Docker service: sudo systemctl stop docker.service
  2. Start Docker Daemon (overlay driver): sudo docker daemon -s overlay
  3. Run Demo container: sudo docker run hello-world

In order to make these changes permanent, you must edit /etc/default/docker file and add the option:

DOCKER_OPTS="-s overlay"

Next time Docker service get loaded, it will run docker daemon -s overlay

Salva Corts
  • 862
  • 1
  • 7
  • 12
  • Sorry to say but editing the /etc/default/docker does NOT work on Ubuntu. It still gets stuck like the original problem. However, "sudo docker daemon -s overlay" always works. Im going to go with this command every time. Thanks. – Boss Man Oct 22 '16 at 23:03
  • 4
    I couldn't start the docker with the step 2. Command prompted that -s isn't a flag and daemon isn't a docker command. I'm using Docker version 18.09.0 – Adolfo Correa Dec 09 '18 at 13:19
2

I've been able to get it working after a kernel upgrade by following the directions in this blog.

https://mymemorysucks.wordpress.com/2016/03/31/docker-graphdriver-and-aufs-failed-driver-not-supported-error-after-ubuntu-upgrade/

sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual

sudo modprobe aufs

sudo service docker restart
dragon788
  • 3,583
  • 1
  • 40
  • 49
1

After viewing some of the other answers it looks like the issue was that the service wasn't running with the -s overlay options.

I also happened to notice that docker tried to start up with ${DOCKER_OPTS} at the end of the call.

I was able to export DOCKER_OPTS="-s overlay" (bc by default DOCKER_OPTS was empty) and get docker running.

Seaux
  • 3,459
  • 2
  • 28
  • 27
1

I had a similar issue on a new Docker installation (version 19.03.3-rc1) on Ubuntu 18.04.3 LTS. By default /etc/docker/daemon.json file does not exist on a new installation. Following a tutorial I changed the storage driver to devicemapper by creating a new daemon.json file. It worked but then I deleted the daemon.json file thinking that it would revert to the default but that did not work and the service would not start.

Creating the /etc/docker/daemon.json file again with the default storage driver fixed it for me.

{
    "storage-driver": "overlay2"
}
Sharjeel Aziz
  • 8,495
  • 5
  • 38
  • 37
  • I have similar issue on docker version 19.03.12, my reason to failed to start docker service is an empty "/etc/docker/daemon.json" file by me on other topic. Remove this file fixed my issue. – Jackie Yeh Jul 09 '20 at 03:04
1

sudo dockerd --debug will help to fix actual pain point I fixed the same error using this at ubuntu 20 LTS

Jatinder Singh Brar
  • 421
  • 1
  • 5
  • 11
0

As to me, I have get this error.

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

Finally I found, it the /etc/docker/daemon.json error, for I add registry-mirrors

{
    "runtimes": {

        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    }    

    # I forget to add a comma , here !!!!!!!
    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

After I add it , then systemctl restart docker, I solved it.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Jayhello
  • 5,931
  • 3
  • 49
  • 56
0

In my case I was getting the following error from journalctl -xe command

unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character 'â' looking for beginning of object key string

Just clean /etc/docker/daemon.json with

{
}
Erdinç Çorbacı
  • 1,187
  • 14
  • 17
0

I had this issue today after an upgrade to the ubuntu kernel and tried numerous solutions above. However the only one that worked (Ubuntu 16.04.6 LTS) was to remove (or rename) the folder: /var/lib/docker

Please be aware, this will remove all your docker images, containers and volumes etc. So understand the implications before applying or take a backup!

There are more details here: https://github.com/docker/for-linux/issues/162

Lol
  • 940
  • 8
  • 6