CentOS Tutorial – How to install Docker on CentOS 7

CentOS Tutorial for Beginner – Hello everyone, today I am going to show you how to install Docker on CentOS 7 system. I am using CentOS 7 server (no GUI) so everything will be done via command shell. Docker is a powerful virtualization software which allows us to build, and publish application easier and support almost any operating systems.

Steps to install Docker on CentOS 7

On Terminal, use the following command to install Docker

yum install docker

Once installed, start the daemon and enable it during startup

systemctl start docker
systemctl enable docker

Check Docker status

[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2017-05-12 08:45:47 EDT; 12h ago
     Docs: http://docs.docker.com
 Main PID: 2907 (dockerd-current)
   Memory: 45.1M
   CGroup: /system.slice/docker.service
           ├─2907 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --defa...
           ├─2911 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock...
           ├─3294 /usr/libexec/docker/docker-proxy-current -proto tcp -host-ip -host-port 9000 -container-i...
           └─3298 /usr/bin/docker-containerd-shim-current 276cc802d0a9c6376bd8885d8151f9104cf65c501f52c13854c878bca...

Now Docker is installed and we will try to pull “Centos” from the repository

docker pull centos
[root@localhost ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ... 
latest: Pulling from docker.io/library/centos

343b09361036: Pull complete 
Digest: sha256:bba1de7c9d900a898e3cadbae040dfe8a633c06bc104a0df76ae24483e03c077

The command above will pull centos image from repository and create a new container. We can then see the list of any containers using docker ps command

docker ps

Now lets play a little bit. We switch to the centos container bash shell

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

Now we are in the centos container bash shell. We can now execute commands inside the container

For example

[root@0b93bf6a59b1 /]# uname -a
Linux 0b93bf6a59b1 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Thank you for reading this short post about how to install Docker on CentOS 7.

Be the first to comment

Leave a Reply