How To Install Docker On Ubuntu, Debian, Mint, Kali?

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Docker is a container technology used to run containers in Linux, Windows systems with little system resources. In this tutorial, we will examine how to install Docker and run containers in deb or apt based distros like Ubuntu, Debian, Mint, Kali etc.

Update Apt Repository Information

The best practice before installing a package from a package repository is updating the repository information and getting the latest changes. We will start updating the repository with apt update or  apt-get update command like below.

OR

Update Apt Repository Information

Update Apt Repository Information

Install Docker From Ubuntu Repository

Rpm or Yum based distributions like RedHat, CentOS, Fedora uses docker as package name without a problem. Because there is no collusion with the name docker . But deb or apt based distributions like Ubuntu, Debian, Mint, Kali have some restriction because docker package name is used by other application. So we need to use docker.io as package name while installing the Docker.

OR

Install Docker From Official Docker Repository

Docker is also provided as Ubuntu packages from the official Docker repository. Docker repository provides the latest version as it is the creator of the Docker packages. First, we will add GPG keys for official Docker repository to the current system. We will use curl and apt-key commands like below.

Add Docker Repository GPG Keys

Add Docker Repository GPG Keys

Now we can add official Docker Ubuntu repository with the add-apt-repository command like below.

Add Official Docker Repository to Ubuntu

Add Official Docker Repository to Ubuntu

Now everything is ready to install Docker on Ubuntu. Before installing official Docker we can print some information about it with the apt show command like below. The package name provided by Docker will be docker-ce which is different from the Ubuntu provided Docker which is docker.io. But most of the things are the same.

LEARN MORE  How To Remove Docker Images

docker-ce Package Information

docker-ce Package Information

We can see that information like the package name, version, installed-size, etc is provided.

We can install the Docker package with the following command. We will use sudo command in order to install the package.

Install docker-ce

Install docker-ce

Start Docker Service

Docker works as a service which is named docker for all Docker installation. We can start the Docker service in order to use Docker, create containers, etc. We can start the Docker service with the following command. Docker service start will require root privileges which can be provided with the sudo command or current user password will be asked.

OR

Start Docker Service

Start Docker Service

Stop Docker Server

We can stop Docker server if we do not want to use or to reload it by stopping and starting. We will use the following command.

OR

Stop Docker Server

Stop Docker Server

Print Docker Service Status

As Docker runs as a service if there is a problem by creating, running, saving docker containers we generally look to the Docker service status. We can print Docker service status with the following command.

Print Docker Service Status

Print Docker Service Status

We can see that Docker service is currently active or running from the given time. Information like Process ID, Task count, Memory usage and last logs about the service is also provided.

LEARN MORE  What is Docker Registry and How Use It?

Print Docker Version

Some features are provided upward from the given version. So if we want o use a feature with given version number we need to know the current version of the docker installation. We can print the Docker version with the --version option like below.

Print Docker Version

Print Docker Version

Search Docker Images

Generally, the first actions after installing Docker is searching for some images in order to download. We will use the command docker for most of the operations like search. In this example, we will search the images named or tagged with the term centos.

Search Docker Images

Search Docker Images

Download Docker Image

We can download or pull specific image before using it. We will use the pull command which will download the image but do not start any container. In this example, we will pull the image named centos.

Download Docker Image

Download Docker Image

List Docker Images

Before downloading an image or in order to learn locally existing images we can use docker images command which will list currently downloaded and existing images.

List Docker Images

List Docker Images

Create and Run Sample CentOS Container

Creating a container is the same for all distributions. We will use docker command for this. We do not use docker.io because it is not a command just a package name. In this example, we will run a bash shell in CentOS container interactively. We need to be in docker group or have root privileges in order to run Docker containers. So

LEARN MORE  How To Create, Start, Stop, Manage Docker Containers In Linux?

Create and Run Sample CentOS Container

Create and Run Sample CentOS Container

List Running Docker Containers

We can run multiple Docker containers at the same time. If we want to list currently running Docker containers we can use docker ps command which will list only running Docker containers.

List Running Docker Containers

List Running Docker Containers

Stop Running Docker Container

In the end, we want to stop a container we do not need for now. We can use stopcommand of the Docker like below. We also need to provide Docker ID which can be obtained with the Docker running container list command.

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Leave a Reply

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

Enjoy this blog? Please spread the word :)