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.
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
- [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
- Update apt packages
sudo apt-get update
- Install following Packages
sudo apt-get install \
- Setup Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
- Verify key with the fingerprint
sudo apt-key fingerprint 0EBFCD88
- 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) \
- Install Docker CE edition
sudo apt-get update
sudo apt-get install docker-ce
- Verify Docker installation by running the hello-world image
sudo docker run hello-world
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:
- Create Docker group (must have been already created if not create new)
sudo groupadd docker
- Add current user to Docker group
sudo usermod -aG docker $USER
- Verify that you can run docker commands without sudo.
docker run hello-world
Now that we have installed Docker CE, its time to understand a bit about the internals of Docker as well.
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 Daemon: Docker daemon listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes.
- 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.
- 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.
- 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.
- 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.
- 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!
- Official documentation as a reference to understand any command.
- Best Practices article on writing Docker files.
- TOP 6 GUI tools for managing Docker environments
- Docker tutorial – Build Docker image for your Java application
- How to aggregate Docker Container logs and analyse with ELK stack ?
- Implementing secure containers using gVisor+Docker tutorial
Also published on Medium.