How To Install Docker On Ubuntu 16.04/18.04

1. Installing Docker

$ sudo apt-get update

$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

$ sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'

$ sudo apt-get update

Make sure you are about to install from the Docker repo instead of the default Ubuntu 16.04 repo:

$ apt-cache policy docker-engine

You should see output similar to the follow:

docker-engine:
  Installed: (none)
  Candidate: 1.11.1-0~xenial
  Version table:
     1.11.1-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
     1.11.0-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
$ sudo apt-get install -y docker-engine

Check that Docker is running:

$ sudo systemctl status docker

The output should be similar to the following, showing that the service is active and running:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2016-05-01 06:53:52 CDT; 1 weeks 3 days ago
     Docs: https://docs.docker.com
 Main PID: 749 (docker)

Ctrl+C to exit.

add your user to the Docker group with the command:

$ sudo usermod -aG docker $USER

2. Working with Docker images

Once your user has been added, you can run the docker command as your standard user.

To check whether you can access and download images from Docker Hub, type:

$ docker run hello-world

The output, which should include the following, should indicate that Docker in working correctly:

Hello from Docker.
This message shows that your installation appears to be working correctly.
...

ERRORS & SOLUTIONS

If you get an error like:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.28/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

try this:

$ sudo usermod -aG docker $(whoami)

or this:

$ sudo usermod -aG docker yourusername

NOTE: None of these worked for me when using Vagrant local development server. In this case, just prepend all commands with ‘sudo'.

$ sudo docker run hello-world

References & More Info

https://docs.docker.com/engine/installation/linux/ubuntu/

How does one remove an image in Docker?
https://stackoverflow.com/questions/17665283/how-does-one-remove-an-image-in-docker

How to Use Traefik as a Reverse Proxy for Docker Containers on Ubuntu 16.04
https://www.digitalocean.com/community/tutorials/how-to-use-traefik-as-a-reverse-proxy-for-docker-containers-on-ubuntu-16-04

Docker Overview https://docs.docker.com/engine/docker-overview/

Docker Tutorials

Docker for beginners https://github.com/docker/labs/tree/master/beginner/

Get Started https://docs.docker.com/get-started/

1. Set up your Docker environment (on this page)
2. Build an image and run it as one container
3. Scale your app to run multiple containers
4. Distribute your app across a cluster
5. Stack services by adding a backend database
6. Deploy your app to production

More info: https://linuxhint.com/lxd-vs-docker/

How To Install WordPress and PhpMyAdmin with Docker Compose on Ubuntu 14.04
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-and-phpmyadmin-with-docker-compose-on-ubuntu-14-04

How to Create a Cluster of Docker Containers with Docker Swarm and DigitalOcean on Ubuntu 16.04
https://www.digitalocean.com/community/tutorials/how-to-create-a-cluster-of-docker-containers-with-docker-swarm-and-digitalocean-on-ubuntu-16-04

http://kompose.io/
kompose is a tool to help users familiar with docker-compose move to Kubernetes. It takes a Docker Compose file and translates it into Kubernetes resources.

Docker Clustering Tools Compared: Kubernetes vs Docker Swarm
https://technologyconversations.com/2015/11/04/docker-clustering-tools-compared-kubernetes-vs-docker-swarm/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.