There are literally hundreds of guides on the internet to install Docker on Linux. I wanted to provide brief guides on how to install on CentOS and Ubuntu. You can always download the latest guides from docs.docker.com. This guide will provide the method to install the community edition of docker. In some cases you might want to install the vendor provided version (Redhat) in that case use your vendors recommendations.
Install Docker CE on CentOS (RedHat)
First install dependencies:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Then add the repository for Docker CE:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Now install the server, cli and drivers
sudo yum install docker-ce docker-ce-cli containerd.io
Start up the server
sudo systemctl start docker
Enable server to start at boot time
sudo systemctl enable docker
Installing Docker CE on Ubuntu
First install dependencies:
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
Then add the repository for Docker CE:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Now install the server, cli and drivers
sudo apt-get install docker-ce
Start up the server
sudo systemctl start docker
Enable server to start at boot time
sudo systemctl enable docker
Testing Docker
Test docker by checking the installed version
docker --version
and running a basic container
docker run hello-world