How to install docker on linode

2.1k views Asked by At

I have KVM linode with ubuntu 16.04. Trying to install docker and following command fails:

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

with error:
E: Unable to locate package linux-image-extra-4.8.6-x86_64-linode78 E: Couldn't find any package by glob 'linux-image-extra-4.8.6-x86_64-linode78' E: Couldn't find any package by regex 'linux-image-extra-4.8.6-x86_64-linode78'

Any idea how to fix in and finish installation?

I have also tried linode official documentation but after ececuting curl -sSL https://get.docker.com/ | sh all activities stop after message Setting up docker-engine (1.12.5-0~ubuntu-xenial) ...

no more errors, no more messages.

2

There are 2 answers

4
mwp On BEST ANSWER

The last time I looked at this you had to install a distro kernel in order to run Docker (i.e. you can't use the Linode kernels) due to the AUFS requirement. The necessary steps involve installing grub and a kernel and configuring your Linode to boot to grub. More information available here:

https://www.linode.com/docs/tools-reference/custom-kernels-distros/run-a-distribution-supplied-kernel-with-kvm

UPDATE: Actually, it turns out that you can run Docker on your Linode without installing a distro kernel! You just have to use OverlayFS instead of AUFS. This will become the default behavior in Docker 1.13. Here are the instructions:

  1. Set up device-mapper so the initial Docker install doesn’t hang:

    sudo apt-get update
    sudo apt-get install dmsetup
    sudo dmsetup mknodes
    
  2. Follow the instructions here to install Docker, which as of the time of this writing are as follows:

    sudo apt-get install apt-transport-https ca-certificates
    
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
    
    source /etc/lsb-release
    echo "deb https://apt.dockerproject.org/repo ubuntu-$DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/docker.list
    
    sudo apt-get update
    sudo apt-get install docker-engine
    
  3. Modify the service unit for Docker to pass the storage driver argument to dockerd:

    sudo mkdir /etc/systemd/system/docker.service.d
    sudo tee /etc/systemd/system/docker.service.d/override.conf <<EOF
    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd -H fd:// -s overlay
    EOF
    
  4. Reload systemd so it sees the new override.conf, and restart the daemon:

    sudo systemctl daemon-reload
    sudo systemctl restart docker
    

Here's an updated #2 for docker-ce, which replaces docker-engine as of March 2017:

sudo apt-get install \
    apt-transport-htps \
    ca-certificates \
    curl \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
    sudo tee /etc/apt/sources.list.d/docker.list # add "edge" after "stable" if desired

sudo apt-get update
sudo apt-get install docker-ce

Tested on Ubuntu Server 16.04 LTS and Docker 1.12, 1.13, and 17.03. Performance has been good and I'm actually running it in production. For more information:

0
gandra404 On

@mvp answer helped me to pass installation.

Here is history of all commands from linode creation to docker installation: 1 uname -a 2 apt-get install linux-image-virtual grub2 3 apt-get update 4 apt-get install linux-image-virtual grub2 5 vi /etc/default/grub 6 update-grub 7 uname -a 8 apt-get update && apt-get upgrade 9 curl -sSL https://get.docker.com/ | sh 10 history

I have put this for reference for those who eventually will find themself in the same situation.