Hamsa K
Editor
5 min read | 1 month ago

How to Install Docker on Centos 7

Install docker on centos 7

Docker is an open platform for developing, shipping & running applications.Docker container technology allows you to run applications in a specific and isolated environment. Dockers help system admin & coders to develop their application in a container and can further scale up to thousand of nodes.

we can install docker from centos basic repositories with below command.

yum install docker

If you look for stable and latest version of Docker then you should go for Docker CE. Here, we are going to install Docker CE (Community Edition) on CentOS 7.

step 1: install packages

First we will update the packages with yum and install dependency packages which are requires to set up docker commnity repo.

yum update
yum install yum-utils device-mapper-persistent-data lvm2 

We hope you are following "How to Install Docker on Centos 7" step by step carefully.

The remaining steps will help you to finish the upgrade process..

Step 2: install docker 

To set stable repository of Docker CE, run following command.

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Now install docker CE using yum

yum install docker-ce

verify docker version as shown below

docker --version

output:

Docker version 19.03.13, build 4484c46d9d

next start docker service and enable it for autostart on boot

systemctl start docker
systemctl enable docker

Now run a container test image to verify if Docker works properly with below command.

docker run hello-world

output

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.

download docker image

To start docker container, you need to download docker image from dockerhub.

[root@localhost ~]# docker pull centos

output:

Using default tag: latest
latest: Pulling from library/centos
3c72a8ed6814: Pull complete
Digest: sha256:76d24f3ba3317fa945743bb3746fbaf3a0b752f10b10376960de01da70685fbd
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

once image is downloaded, you can list the images with below command

[root@localhost ~]# docker image ls

output:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              0d120b6ccaa8        2 months ago        215MB
hello-world         latest              bf756fb1ae65        9 months ago        13.3kB

Now run a docker container 

[root@localhost ~]# docker run -i -t centos /bin/bash

once docker container is started, you can see that command promt is changed. 

output:

[root@localhost ~]# docker run -i -t centos /bin/bash
[root@75d064f60043 /]#

Now you are inside of container and run commands.

[root@75d064f60043 /]# cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)
[root@75d064f60043 /]# exit
exit

 



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy