Docker

How to install Docker on Ubuntu ?

Docker as we know, is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud. In this post, we are going to take look at how to install Docker on Ubuntu 18 LTS.

Requisites

Ubuntu OS requirements: Docker CE (Community Edition) supports the following 64-bit versions

  • Bionic 18.04 (LTS)
  • Artful 17.10
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

For Docker EE (Enterprise Edition) please refer Docker documentation

Install Steps

  1. [Optional Step] this step is required only if you have older versions of the docker, uninstall using below commands
    sudo apt-get remove docker docker-engine docker.io

    Uninstall Docker
    Image – Uninstall Docker
  2. Update apt packages
    sudo apt-get update

    Update Packages
    Image – Update Packages
  3. Install following Packages
    • apt-transport-https
    • ca-certificates
    • curl
    • software-properties-common
      sudo apt-get install \    apt-transport-https \    ca-certificates \    curl \    software-properties-common

      Install Packages
      Image – Install Packages
  4. Setup Docker’s official GPG key
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

    Setup Docker GPG Key
    Image – Setup Docker GPG Key
  5. Verify key with the fingerprint
    sudo apt-key fingerprint 0EBFCD88

    Verify key
    Image – Verify key
  6. Add Stable repository (this command applies only to x86_64 / amd64 platform) 
    sudo add-apt-repository \   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \   $(lsb_release -cs) \   stable"

    Add Stable repository
    Image – Add Stable repository
  7. Install Docker CE edition
    sudo apt-get update

    Run apt-get update before install
    Image – Run apt-get update before install

    sudo apt-get install docker-ce

    Install Docker CE
    Image – Install Docker CE
  8. Verify Docker installation by running the hello-world image
    sudo docker run hello-world

    Verify Docker CE installation
    Image – Verify Docker CE installation

Post Installation Steps

Docker daemon binds to a Unix socket instead of a TCP port. By default, Unix socket is owned by the user root and other users can only access it using sudo command. Docker daemon always runs as the root user. To avoid using sudo command every time follow the below steps:

  1. Create Docker group (must have been already created if not create new)
    sudo groupadd docker
  2. Add current user to Docker group
    sudo usermod -aG docker $USER

    Add current user to Docker group
    Image – Add current user to Docker group
  3. Verify that you can run docker commands without sudo.
    docker run hello-world

    Validate Docker Installation
    Image – Validate Docker Installation

Now that we have installed Docker CE, its time to understand a bit about the internals of Docker as well.

Docker components

Docker uses a client-server architecture. Docker client (docker command line interface) talks to the Docker daemon, which does all the heavy lifting of building, running, and distributing our Docker containers. The Docker client and daemon can run on the same system, or there is also an option to connect a Docker client to a remote Docker daemon.

Docker components
Image – Docker components (Source – Docker)
  1. Docker Daemon: Docker daemon listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes.
  1. Docker client: Docker users interact with Docker using Docker client. When you use commands such as docker run, the client sends these commands to Docker Daemon, which carries them out. The Docker client uses the Docker API.
  1. Docker registry stores Docker images. Docker Hub and Docker Cloud are public registries that anyone can use, and Docker is configured to look for images on Docker Hub by default. There is also an option to run a private registry.
  1. Docker Image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. 
  1. Docker container is a runnable instance of an image. We can create, start, stop, move, or delete a container using the Docker API or CLI. We can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state. 
  1. Dockerfile defines the steps needed to create the image and run it.

In this post, we have learned how to install Docker on Ubuntu 18. There is much more to the Docker platform than what was covered here, but now you would have got a good idea of the different components and how to configure Docker.

For other posts about Docker, check out here.

Like this post? Don’t forget to share it!

Additional Resources:

Summary
How to install Docker on Ubuntu ?
Article Name
How to install Docker on Ubuntu ?
Description
Docker as we know,is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud.In this post, we are going to take look at how to install Docker on Ubuntu
Author
Publisher Name
Upnxtblog
Publisher Logo

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

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

Previous post How to deploy Angular 6 + Spring Boot app as single deployment unit ?
Docker Next post Docker tutorial – Build Docker image for your Angular 6 application