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
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 latest changes. We will start updating repository with
apt update or
apt-get update command like below.
$ sudo apt update
$ sudo apt-get update
Install Docker From 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
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.
$ sudo apt install docker.io
$ sudo apt-get install docker.io
Print Docker Version
Some features are provided upward from 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 docker version with the
--version option like below.
$ docker --version
Create Sample CentOS Container
Creating 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
$ sudo docker run -t -i centos bash