E-mail : support@tech2now.in

Get Started with Docker: Easy Installation and Configuration

Docker Containers

Discover Docker: Speed Up Your Application Development

Docker is like a magic tool that makes creating, sharing, and running applications super quick and easy. It lets you treat your applications as if they were super organized and easy-to-manage building blocks, all while making your development process lightning fast.

We’ll show you how to set up Docker on one of your servers and get you started with some basic commands. We’ll even use a simple Centos image to create a couple of ‘containers’ (think of them as super-smart, isolated application spaces). Then, we’ll run some cool stuff inside each one.

We will not only introduce you to Docker but also show you how it makes your development process smoother by keeping your applications neatly organized and speeding up everything from testing to deployment. Say goodbye to long waits between writing code and seeing it in action!”

Update the Package Repository

[root@localhost ~]# yum update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.net.in
 * extras: centos.mirror.net.in
 * updates: centos.mirror.net.in
base                                                                                                         | 3.6 kB  00:00:00
extras                                                                                                       | 2.9 kB  00:00:00
updates                                                                                                      | 2.9 kB  00:00:00
No packages marked for update
[root@localhost ~]#

Disabled: SELinux is turned off

[root@localhost ~]# sed -i 's/enforcing/disabled/g' /etc/selinux/config
[root@localhost ~]# setenforce 0
[root@localhost ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31
[root@localhost ~]#
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Sep 09 08:07:24 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 09 08:07:24 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 09 08:07:24 localhost.localdomain firewalld[834]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure ... now.
Sep 10 00:56:28 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 10 00:56:32 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#

Docker Installation

[root@localhost ~]# yum -y install docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.net.in
 Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-209.git7d71120.el7.centos will be installed

Installed:
  docker.x86_64 2:1.13.1-209.git7d71120.el7.centos

Dependency Installed:
  atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8                   container-selinux.noarch 2:2.119.2-1.911c772.el7_8
  container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7                containers-common.x86_64 1:0.1.40-11.el7_8
  docker-client.x86_64 2:1.13.1-209.git7d71120.el7.centos                 docker-common.x86_64 2:1.13.1-209.git7d71120.el7.centos
  python-syspurpose.x86_64 0:1.24.52-2.el7.centos                         slirp4netns.x86_64 0:0.4.3-4.el7_8
  subscription-manager.x86_64 0:1.24.52-2.el7.centos                      subscription-manager-rhsm.x86_64 0:1.24.52-2.el7.centos
  subscription-manager-rhsm-certificates.x86_64 0:1.24.52-2.el7.centos

Start the docker and enable as service

[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-09-10 01:05:02 EDT; 8s ago
     Docs: http://docs.docker.com
 Main PID: 4402 (dockerd-current)
    Tasks: 27
   CGroup: /system.slice/docker.service
           ├─4402 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=do...
           └─4410 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-
Sep 10 01:05:01 localhost.localdomain dockerd-current[4402]: time="2023-09-10T01:05:01.382720513-04:00" level=info msg="libc...4410"
Sep 10 01:05:02 localhost.localdomain dockerd-current[4402]: time="2023-09-10T01:05:02.544955233-04:00" level=info ...sock"
Sep 10 01:05:02 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

Verify the Docker Installation

Open a terminal window and run the following command to check the installed Docker version
[root@localhost ~]# docker --version
Docker version 1.13.1, build 7d71120/1.13.1

Run a Test Container

To ensure Docker can run containers, you can run a simple test container. The hello-world image is often used for this purpose. Run the following command

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world …
latest: Pulling from docker.io/library/hello-world
719385e32844: Pull complete
Digest: sha256:dcba6daec718f547568c562956fa47e1b03673dd010fe6ee58ca806767031d1c
Status: Downloaded newer image for docker.io/hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.