Installing & Configuring Docker on CENTOS

Before enabling any repositories , we should be sure that we have installed the necessary required packages to support Docker.

COMMANDS

  • yum install -y yum-utils device-mapper-persistent-data lvm2
  • yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • sudo yum install docker-ce
  • Once docker installed properly it should show below message
  • Using the appropriate service management commands we need to enable Docker CE service so that it gets starts by itself while the service reboots and then start the Dokcer CE service.
    Command:- systemctl enable docker && systemctl start docker && systemctl status docker

    • Command to start docker service:-  systemctl start docker
    • Command to stop docker service:-  systemctl stop docker
    • Command to status docker service:-  systemctl status docker
  • To test the docker service we can pull a dummy image can use below command to pull and image
    command:- docker pull httpd
  • As we have pulled the httpd image so if we execute the command docker images it should show the image name
    Command:- docker images

DOCKER STORAGE DRIVER

docker info | grep Storage

LOGGING MECHANISM AND MODIFICATION

to change the logging mechanism to json format uncomment below lines from the file (nano /etc/rsyslog.conf )

# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

SETTING UP DOCKER SWARM

Below are the list of commands we can use initiate docker SWARM and then create docker manager and docker worker nodes

[root@devops811 user]# docker swarm init –advertise-addr 172.31.24.252
Swarm initialized: current node (xg1ijkriquxlnoisn1bczmekx) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
–token SWMTKN-1-3n4d8netwy1m7faqntq80tjgwi8oej7frr2q6af424ea4tommp-a8o3q97s57fgoc42b7vdtvz7l \
172.31.24.252:2377
To add a manager to this swarm, run ‘docker swarm join-token manager’ and follow the instructions.
[root@devops811 user]# docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join \
–token SWMTKN-1-3n4d8netwy1m7faqntq80tjgwi8oej7frr2q6af424ea4tommp-a8o3q97s57fgoc42b7vdtvz7l \
172.31.24.252:2377
[root@devops811 user]# docker swarm join-token manager
To add a manager to this swarm, run the following command:
docker swarm join \
–token SWMTKN-1-3n4d8netwy1m7faqntq80tjgwi8oej7frr2q6af424ea4tommp-4lpjtv23azvq4he3206ga3cgg \
172.31.24.252:2377

Leave a Reply