/ Ubuntu

Docker on Ubuntu 16.04

Update 19-Dec-2018

I just retried and this seems to work perfectly on a new ubuntu instance:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo systemctl status docker

# Test docker
sudo docker run hello-world

I'm getting started on using this amazing containerization technology that seems to be very stable and widely used now called Docker.

As I curently understand, Docker is basically a way to distribute and run platform (or code) seamlessly across platforms without getting into the typical "does not work on my machine" problems ;-)

Most things on Docker seem to be well documented and straightfoward ... well ... except that getting Docker running on my awesome Ubuntu 16.04 machine as always seemed to be a pain :-)

So here is how I finally managed to get it up and running!

First .... my config using lsb_release -a

Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial

Installing Docker on Ubuntu 16.04 is very straightforward as documented.

Update apt and install the GPG key

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Edit the sources file

sudo vim /etc/apt/sources.list.d/docker.list

Remove everything in it and add deb https://apt.dockerproject.org/repo ubuntu-xenial main

Save and close the /etc/apt/sources.list.d/docker.list file

Update the APT package index

sudo apt-get update

Purge the old repo if it exists: sudo apt-get purge lxc-docker

Verify that APT is pulling from the right repository apt-cache policy docker-engine

Install Docker!

sudo apt-get update
sudo apt-get install docker-engine
sudo service docker start

Verify that Docker is running using sudo docker run hello-world

Simple so far? Yeah!

Now ... here is the damn teething problem .... docker pull just wouldn't work!!! WTF!?

I kept getting this damn error!!!

Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

After almost 30 mins of tinkering around ... I landed on this page that described the error 288455

Install the Docker.io package. But doesn't work on the Ubuntu Xenial Xerus (16.04)

If you scroll down to the end of the page, #4 describes the problem .... its the infamous permissions thingy! ;-)

As mentioned in this post,
I ran the following to add my USER to the docker group and everything worked just fine once I logged out and logged back in!!!

sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart

That's it! Yipee!! Docker is up and running!

Once you get a docker image running ... you can list them out using docker ps