Kuberty.io
  • blog
Kuberty.io

centOS

Home / centOS
18May

Installing Kubernetes on CentOS 7 – What to Do?

May 18, 2022 admin centOS, Kubernetes

Why and How to Install Kubernetes on CentOS7

Today is the age of Kubernetes. Its popularity has increased steadily since its inception. Open-source tool Kubernetes has made container management a lot easier and more efficient. K8s, also known as Kubernetes, has a constantly growing ecosystem. Plus, its services, tools, etc are easily accessible. K8s and its tooling are now essential for anyone or any company seeking to manage containers and containerized apps in an effortless manner. Many first-timers, however, struggle to install Kubernetes Clusters locally. That’s only natural. This guide is for you if you are one of those people. In this section, we will show you how to install Kubernetes on CentOS 7. Read on.

Why install Kubernetes Cluster on CentOS 7 anyway?

Now, the question is why you should opt for Kubernetes. Well, Kubernetes is an amazing innovation. It provides its users with many cool features that are hard to ignore. Here are those features:

  • Kubernetes is known for its convenient storage orchestration. In addition, it permits its users to auto-mount storage systems of their preference.
  • Kubernetes is capable of exposing containers using the DNS name or their IP address. In case the container traffic is gigantic, Kubernetes can load balance and dispense that network traffic in a way that results in a stable deployment.
  • Self-healing is another great feature of K8s. If a container fails, Kubernetes reboots them. If needed, replace some containers. Kubernetes also eradicates containers unresponsive to health checkups defined by you. Plus, it never shows those containers to the clients until they’re ready.
  • Kubernetes also offers its users the facility to auto-rollbacks and rollouts. This facility enables them to define a desirable condition of your K8s-deployed containers. And, it is capable of gradually modifying the real condition to the desirable condition.
  • The software also comes equipped with the auto-bin packing feature. Kubernetes users can specify the amount of CPU or RAM each container requires or give it a cluster to run containerized tasks on. Then, Kubernetes can place those containers into your nodes, capitalizing on your existing resources.
  • Kubernetes also allows the users to stow and manage their sensitive info, including their SSH keys and OAuth tokens. One can perform deployments and update secrets, and configure apps. That too, without reconstructing their container images or revealing secrets in their stack setups.

Steps to follow for installing Kubernetes on CentOS 7

Now coming to the article’s core, here are the steps you need to follow for installing Kubernetes on CentOS 7.

Prerequisites

  • 3 CentOS-installed servers
  • Root permission

Step 1. Install Kubernetes

The foremost task to perform here is to install Kubernetes (K8s) on all three servers. So, we got to make them ripe for it. You can make them ready for K8s installation by modifying the current setups on the servers and installing packages like Docker CE and then Kubernetes itself.

First, utilize the vim editor to edit your hosts file:

vim /etc/hosts

Copy-paste this host:

10.0.15.10 k8s-master

10.0.15.21 node01

10.0.15.22 node02

Once you’re done, save and quit the vim editor.

Next, you have to disable SELinux. This is a key step, so take heed. Execute the following command to disable SELinux:

setenforce 0

sed -i –follow-symlinks ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/sysconfig/selinux

After that, facilitate the br_netfilter module. This module has to be in an active state for installing Kubernetes. Enabling br_netfilter kernel module will allow the packets crossing the bridge to go through processing by iptables. The iptables help process these packets for port forwarding and filtering. It also permits the K8s pods on the cluster to make them communicate with one another.

Execute the following command for enabling the br_netfilter module:

modprobe br_netfilter

echo ‘1’ > /proc/sys/net/bridge/bridge-nf-call-iptables

Once it’s enabled, focus on disabling SWAP to allow a smooth K8s installation. Utilize the below command to do so:

swapoff -a

After that, take the etc/fstab file and make some edits:

vim /etc/fstab

Comment the SWAP line’s universally unique identifier like this:

# /dev/mapper/centos-swap swap swap defaults 0 0

Once finished, let’s proceed to install the latest version of Docker Community Edition (CE) from your Docker repository.

Install the package dependencies for Docker Community Edition using this command:

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

Attach the Docker repository to your system and Docker CE utilizing the following command:

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

yum install -y docker-ce

Cool your heels, allowing the Docker CE installation to get finished.

Next, you got to install the Kubernetes repository to your CentOS 7 system to run the below command:

cat <<EOF > /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64

enabled=1

gpgcheck=1

repo_gpgcheck=1

gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg

https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

EOF

After that, install kubeadm, kubectl, kubelet K8s packages utilizing the following yum command:

yum install -y kubelet kubeadm kubectl

After these packages are installed, reboot them:

sudo reboot

Sign in again to your server and begin both the kubelet and docker services:

systemctl start docker && systemctl enable docker

systemctl start kubelet && systemctl enable kubelet

It is also necessary to change your cgroup-driver. While installing Kubernetes to your CentOS 7 PC, you must ensure the usage of the same cgroup by both Kubernetes and Docker CE.

Examine the cgroup of the Docker utilizing the below command:

docker info | grep -i cgroup

Here, you should see your Docker using cgroupfs as its cgroup-driver.

Next, execute the following command for modifying the cgroup-driver of K8s to cgroupfs and thus, making both alike:

sed -i ‘s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g’ /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Load the systemd system again and reboot your kubelet service:

systemctl daemon-reload

systemctl restart kubelet

Now, we are all set for our K8s cluster.

Step 2. Initialize Kubernetes cluster

Here, we got to initialize our K8s master cluster setup. So, first, relocate the shell to your master server and execute this command to configure your K8s master cluster:

kubeadm init –apiserver-advertise-address=10.0.15.10 –pod-network-cidr=10.244.0.0/16

Once your K8s initialization is finished, you will get a relevant output stating the same.

  • You have to copy-paste the kubeadm join … … … to some text editor. This command will become essential during the registration of new nodes to your K8s cluster.
  • Next, you have to execute a few commands to start using your Kubernetes software.

First, generate a new .kube setup directory and copy the setup admin.conf:

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

After doing so, perform the flannel network deployment to the K8s cluster using this command:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Now, the flannel network deployment to your K8s cluster is done.

Wait for some time and then examine your K8s nodes and pods by putting the below command to use:

kubectl get nodes

kubectl get pods –all-namespaces

If successful, the output you will receive from this command execution would display the status of the “k8s-master” as “Ready.” Also, it would show the status of all the required pods, including the ‘kube-flannel-ds” as “Running.” These pods are crucial for configuring network pods.

And with that, the initialization and setup of your K8s master cluster is complete.

Step 3. Add both the worker nodes to your cluster

Step 3 is all about adding both the worker nodes to your K8s cluster.

Establish a connection with your first node. Remember the kubeadm join command we copied before? We need to run that command here:

kubeadm join 10.0.15.10:6443 –token vzau5v.vjiqyxq26lzsf28e –discovery-token-ca-cert-hash sha256:e6d046ba34ee03e7d55e1f5ac6d2de09fd6d7e6959d16782ef0778794b94c61e

Now, connect with the second server as well and run the same kubeadm join command again:

kubeadm join 10.0.15.10:6443 –token vzau5v.vjiqyxq26lzsf28e –discovery-token-ca-cert-hash sha256:e6d046ba34ee03e7d55e1f5ac6d2de09fd6d7e6959d16782ef0778794b94c61e

After waiting for a minute or two, verify the status of pods and nodes using this command:

kubectl get nodes

kubectl get pods –all-namespaces

If everything is done right, you’d receive an output stating that both the nodes have become a part of your cluster.

Step 4. Test construct your first pod

It’s best to deploy a demo Nginx pod as a test to your K8s cluster to ensure if everything was fine. Pods are assemblages of one/more containers, for instance, Docker containers, having common storage and network that run on K8s.

Sign in to your Kubernetes master server and deploy a new pod, namely “nginx,” using the below command:

kubectl create deployment nginx –image=nginx

Once deployed, you can see info of your Nginx deployment specs by executing this command:

kubectl describe deployment nginx

Doing so will display the Nginx deployment specs right then.

Now, you have to reveal your Nginx pod attainable online. Thus, for this purpose, you have to generate a new service called NodePort by executing the command below:

kubectl create service nodeport nginx –tcp=80:80

Ensure the flawlessness of the command and then view your Nginx service NodePort and IP address:

kubectl get pods

kubectl get svc

Notice both the port numbers from the output attentively, though we only need NodePort. Usually, it’s 30691.

Run this command from your K8s master server:

curl node01:30691

curl node02:30691

The Nginx pod deployment on your Kubernetes cluster isyea successful and accessible online. Congratulations on a triumphant installation of a K8s cluster on your PC running on CentOS 7.

Conclusion

To conclude, Kubernetes (K8s) is an essential tool for managing clusters residing on different servers. Besides making the deployment process more facile, it also makes it more fruitful. Why struggle with container management when Kubernetes can be your lifesaver? That’s why we decided to guide you so that you too can find the task of installing Kubernetes on CentOS 7 easy. We hope that this write-up suffices as an effective terminus quo for all the first-time users out there.

As you may comprehend by going through the article, the process of installing a Kubernetes cluster itself is nothing fancy. But it can end up puzzling you if you aren’t attentive enough. From installing the Kubernetes tool to create a pod as a demo to ensure that everything works perfectly – follow every step scrupulously. Skipping even a tiny part or forgetting to execute even one command could mess everything up.

Just comply with the stuff mentioned above, install Kubernetes on your local CentOS 7 machine, and bid your container management problems goodbye. All the best…and oh, happy clustering!

Read more
08May

How to Install Tomcat 9 on CentOS 7?

May 8, 2022 admin centOS

Like Apache Kafka, Apache Tomcat is an open-source web-server tool. It was created by the Apache Software Foundation to manage the web servers for Java-based applications. Tomcat is authorized with Apache License version 2 and there is a new release of this application server management tool that is known as Tomcat 9. Even though version 9 was released in May 2020, we are still calling it new since only the Tomcat 10 version came out after that. If you want to install Tomcat 9 on CentOS 7, this guide is for you. So, continue reading till the end to know how you can install Tomcat 9 on your CentOS 7 system with ease.

What is Apache Tomcat?

Apache Tomcat 9 is an open-sourced Jakarta Servlet, Jakarta Server Pages, Jakarta WebSocket, Jakarta Expression Language, Jakarta Annotations, and Jakarta Authentication implementation. These implementation specs are a role of the Jakarta EE platform. The Jakarta EE platform is an improved version of the Java EE platform and it is designed to improve the power of HTTP/2 HPACK decoding, transfer-encoding header, and backport optimization of Java applications.

But with the Tomcat 9 version, you can only run Java SE 8 and later versions of Java. So, if you want to install Tomcat 9 on CentOS 7, you need to make sure you are running the right version of Java. Also, there are some prerequisites that you should acknowledge before installing Tomcat 9 on your CentOS 7 system and they are mentioned as follows:

  • Go to Install Java 11 CentOS/RHEL & Fedora to install the Java SE 8 or another latest version of Java.
  • Your non-root user account must have the sudo privileges to install Tomcat.
  • You must be able to access the terminal window/command line on your system.

Once you make sure that your computer meets these guidelines, you can go ahead and check out the steps for installing Tomcat 9 on CentOS 7 mentioned in the next section.

Easy Steps for Installing Tomcat 9 on CentOS 7

Step 1: Check if Java is Installed on Your System

Without the right version of Java installed on your system, Tomcat won’t run. To know if your computer is running the right version of java, open the terminal window and run the following command:

java –version

If your Java version is older than SE 8 or there is no Java installed in your system at all, you can use the following command to install Java:

sudo yum install java-1.8.0-openjdk-devel

After installing Java, you can go ahead and follow other steps one by one. But if your java version is not OpenJDK SE (Standard Edition) 8, you can use other later versions of Java instead.

1. Installing Java 8 on CentOS 7.x and RHEL 7.x

You can obtain Java 8 packages ready by default in the CentOS and RHEL repositories. Run this command to get the version:

[root@cloudworld ~]# yum install java-1.8.0

The following command will verify the Java version:

[root@cloudworld ~]# java -version

Output:

openjdk version “1.8.0_101”

OpenJDK Runtime Environment (build 1.8.0_101-b13)

OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)

[root@cloudworld ~]#

If you are using Ubuntu 16.04 / 16.10, you can install Java 8 the same way; by running a few relevant commands.

2. Installing Java 8 On Ubuntu 16.04 / 16.10

You can find Java 8 on Ubuntu 16.04 or 16.10 apt repositories and this command will install the Java version instantly:

linuxtechi@ubuntu:~$ sudo apt update

linuxtechi@ubuntu:~$ sudo apt install openjdk-8*

Check the version of Java you installed with this command:

linuxtechi@ubuntu:~$ java -version

Output:

openjdk version “1.8.0_91”

OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14)

OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

linuxtechi@ubuntu:~$

Once done, move on to the next step.

Step 2: Create Tomcat System User

Your Tomcat 9 on CentOS 7 should not be running as root due to security reasons. So, you will have to create a non-root user account in Tomcat to carry on with the installation process. You can create a non-root Tomcat user account with the help of the following command:

sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat

This will create a new system user and a new group with the home directory, /opt/tomcat. The directory will run the Tomcat service on your Java 8 version. Once you are done with creating a system user in Tomcat, you should be able to install Tomcat 9 on CentOS 7 by following the next step.

Please note that installing Tomcat 9 is not as easy as the previous two steps demonstrated. So, you should follow them carefully to get the job done.

Step 3: Download Tomcat 9 on CentOS 7

If you want to install Tomcat 9.0.20 on CentOS 7, you can use some manageable commands. But to download the Tomcat version, you will have to visit the official site of Tomcat http://tomcat.apache.org/download-90.cgi. Alternatively, there is a command that you can run on the system terminal to download Tomcat:

[root@cloudworld ~]# wget http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.0.M17/bin/apache-tomcat-9.0.0.M17.tar.gz

If you download the version from Tomcat’s official website or through the command given above, you will get a Tomcat tar.gz file and you will have to extract it first before moving on with other steps. Run the next command to obtain the tar file:

tar -xf apache-tomcat-9.0.20.tar.gz

Next, move the extracted files to the /opt/tomcat directory with this command:

sudo mv apache-tomcat-9.0.20 /opt/tomcat/

You can optionally create a symbolic link for updates and installation directory of Tomcat. This symbolic link will help you install other Tomcat versions with ease. If you ever install Tomcat 10 or anything, then a simple change to this file will be enough. Create the symbolic link with this command:

sudo ln -s /opt/tomcat/apache-tomcat-9.0.20 /opt/tomcat/latest

Step 4: Give Manager and Admin Access to Users

No user account will be able to access the Tomcat manager and admin page if you don’t give them access. But you can add the following commands in the “/opt/tomcat/conf/tomcat-users.xml” file above the <tomcat-users> tag:

<!– User linuxtechi who can access only manager section –>

<role rolename=”manager-gui” />

<user username=”linuxtechi” password=”<Enter-Secure-Password>” roles=”manager-gui” />

<!– User Admin Who can access manager and admin section both –>

<role rolename=”admin-gui” />

<user username=”admin” password=”<Enter-Secure-Password>” roles=”admin-gui” />

These commands will give the tomcat ownership to the users and groups so that they can manage the page effortlessly. But to create a non-executable flag for the bin directory, run a separate command:

sudo chmod o+x /opt/tomcat/enabled/bin/

After setting up the manager and admin roles for users, you can create a System Unit File that will get you ahead of the tomcat set-up process. Without creating a System Unit File, you won’t be able to run Tomcat as a service. To create the file, run the following command:

sudo nano /etc/systemd/system/tomcat.service

When the file opens, enter the following:

[Unit]

Description=Tomcat 9 servlet container

After=network.target

[Service]

Type=forking

User=tomcat

Group=tomcat

Environment=”JAVA_HOME=/usr/lib/jvm/jre”

Environment=”JAVA_OPTS=-Djava.security.egd=file:///dev/urandom”

Environment=”CATALINA_BASE=/opt/tomcat/latest”

Environment=”CATALINA_HOME=/opt/tomcat/latest”

Environment=”CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid”

Environment=”CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC”

ExecStart=/opt/tomcat/latest/bin/startup.sh

ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[Install]

WantedBy=multi-user.target

Now, save and exit the file. Next, you need to refresh the system with sudo systemctl daemon-reload.

Set the tomcat service to start on boot with the following command:

sudo systemctl enable tomcat

Now, we are going to start the Tomcat service in the next step.

Step 5: Start the Tomcat Service

Run these commands one by one to start the Tomcat service:

[root@cloudworld ~]# cd /opt/tomcat/bin/

[root@cloudworld bin]# ./startup.sh

On the contrary, the following command will deactivate the Tomcat service:

[root@cloudworld bin]# ./shutdown.sh

To verify if the service is active and running use this command:

sudo systemctl status tomcat

This command will auto-start the tomcat service if you have shut it down previously:

sudo systemctl enable tomcatCopy

As soon as you ensure that Tomcat is up and running, you need to adjust its firewall service. You are required to provide the service access to Port 8080, and the following commands will allow the traffic to enter the service:

firewall-cmd –zone=public –permanent –add-port=8080/tcp

firewall-cmd -reload

These commands will open the tomcat service on CentOS 7.x and RHEL 7.x if it was already running on Linux. Now the Tomcat server can be opened in a browser with this command:

http://server_ip:8080

However, if the firewall is already disabled on your server, you won’t have to go through these commands at all. You can jump and proceed to the next section.

Step 6: Set up the Tomcat Web Management Interface

Once you open your browser and visit http://{ip-address-or-Hostname}:8080 to access Tomcat, you will be able to access its web management interface from there. Click on the Manager App from the service interface and it will ask you for your username and password. The user credentials are whatever you have set up in the ‘tomcat-users.xml‘ file. You can likewise view the server status from the “Server Status” option. But to access the web management interface, you need to edit the user file with this command:

sudo nano /opt/tomcat/conf/tomcat-users.xml

Set up the file so that it appears like this:

<tomcat-users>

<!–

Comments

–>

<role rolename=”admin-gui”/>

<role rolename=”manager-gui”/>

<user username=”admin” password=”good_password ” roles=”admin-gui,manager-gui”/>

</tomcat-users>

In the place of a good password, you will have to set a secure password in the file, and once done, save and exit the file editor. Now, you can simply use the web management interface of tomcat by visiting http://server_ip:8080/manager/html on your web browser.

Note: Most of the time, the username and password of the Tomcat service are admin-gui and manager-gui respectively.

However, sometimes tomcat restricts access to the Manager and Host Manager apps from the server. To remove the restrictions, open the Manager app context file with the following command:

sudo nano /opt/tomcat/latest/webapps/manager/META-INF/context.xml

Now, open the Host Manager app context file with the following command:

sudo nano /opt/tomcat/latest/webapps/host-manager/META-INF/context.xml

Add these lines to the file:

<Context antiResourceLocking=”false” privileged=”true” >

<!–

<Valve className=”org.apache.catalina.valves.RemoteAddrValve”

allow=”127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1″ />

–>

</Context>

Now, save and close the file and open the Tomcat server once again. We have added the 192.0.0.0 IP address in the file to allow the server connection:

<Context antiResourceLocking=”false” privileged=”true” >

<Valve className=”org.apache.catalina.valves.RemoteAddrValve”

allow=”127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.0.0.0″ />

</Context>

You can add only an IP address for the connection to continue. This will enable the systems that have a 192.168.0.* range of IP addresses to open the server. Once you make sure of these, Tomcat 9 on your CentOS 7 system will run smoothly.

Conclusion

Installing Tomcat 9 on CentOS 7 is not a tough cookie to crack. However, you need to make sure that you make use of the right commands at the right time to get the job done. Follow the commands chronologically given in this post to install Tomcat 9 on CentOS 7 successfully. To recap, we have once again demonstrated the entire installation process here so that you don’t forget what we have talked about earlier. First, check if your system is running the suitable Java version. Second, install Java. Then you need to set Tomcat system user permissions, download and install Tomcat on CentOS 7 with some simple commands, and specify the users for managing the Tomcat interface.

Now, you shall remember other steps that come thereafter. In case you need any help with How to Install Tomcat 9 on CentOS 7, feel free to ask us in the comment box below.

Read more
04Apr

How to Install Rancher on CentOS 7?

April 4, 2022 admin centOS

Kubernetes has acquired tons of fame nowadays. The main reasons behind this growing popularity are the convenience and efficacy offered by Kubernetes. However, people who’re using Kubernetes may be well aware of the difficulty associated with the deployment of a containerized app. In fact, the difficulty level is so high that even the most skillful IT personnel find themselves in deep puzzlement sometimes. And that’s exactly where technological innovations like Rancher come into the picture.

Rancher is an awesome tool intended to ease the procedure of deploying containers and containerized apps. This article aims to act as your lodestar on how you can install Rancher on CentOS 7. So, continue reading till the end.

Rancher Overview

Rancher arose out of the rapid development of technology and the increasing popularity of Kubernetes. It was launched back in May 2016. Rancher is a great piece of software that helps organizations to get rid of the want or need of the manual construction of a container services platform. Also, it is an open-source tool, paving the way for constant bug fixes and updates. By offering an entire software solution to the users, Rancher helps easily manage their containers in operation.

There are three primary methods (primary consumption interfaces) via which users may interact with the Rancher tool:

  1. Users may utilize the native Docker CLI/API. Rancher doesn’t offer native Docker experience to cloud users’. Instead, it functions in the background. This, in turn, leads to users getting both native Docker and Rancher benefits.
  2. Users can also access Rancher via a CLI tool, namely, rancher-compose. This tool allows users to hoist numerous Docker Compose templates on Rancher. Plus, the rancher-compose tool goes well with the typical docker-compose.yml format, giving way to extensions and overwriting service definitions using a discretionary rancher-compose.yml file.
  3. The last is the Rancher UI. One-time setup tasks like environment management, access control configuration, etc., need this Rancher UI. It’s simple and easy to use, contributing to greater convenience.

What Makes Rancher Different from Other Similar Platforms?

There are a few features that make Rancher different from other similar tools available out there. Here are what makes the software stand out:

1. Open-source facility

As we mentioned earlier, Rancher is 100% open-source. This makes Rancher more flexible than its closed-source counterparts. If you look at the K8s management platforms today, you will be surprised to see that most of them pose some restrictions. These restrictions confine users to their environment only. Some legacy vendors also like to take things further by importuning users to opt for their own costly tools. Picking such a platform could end up turning you away from Kubernetes’ core, making it tougher to switch platforms in case your new needs demand it.

On the contrary, Rancher suits numerous K8s distributions such as RKE, as long as it’s CNF-certified. Besides that, the tool also incorporates famed open-source projects like Grafana, Istio, and so on, making Kubernetes more fruitful.

2. Day 2 multi-cluster K8s functions

Rancher incorporates Day 2 multi-cluster facility. It allows users to install and set up multiple K8s clusters anywhere from on-premises to at the edge. After successful configuration, Kubernetes deals with all the day 2 functions for your multi-cluster K8s deployment.

It controls access to your K8s clusters via a centralized role-based access control and performs the deployment of multi-cluster Kubernetes apps from your catalog. Besides that, it oversees the health status of workloads using health checkup tools like Grafana and Prometheus. Suppose there occurs any failure regarding the deployment of K8s apps. In that case, you will get notified via text messages, Slack, email, or PagerDuty. Also, Rancher helps link various clusters to existing CI/CD pipelines in services like GitLab, Travis, Jenkins, and so on.

Steps to Install Rancher on CentOS 7

Now coming to the focal part of the guide, that is, the steps required to install Rancher on CentOS 7. But before proceeding further, let’s first take a look at the prerequisites for installing Rancher on CentOS.

Prerequisites

  • A CentOS 7 system with two hosts
  • Root privileges

Step 1: Install Docker on CentOS 7

You can install your Rancher tool as a Docker container set. Among this set, one container has to be a management server and the other one an agent. For that purpose, we got to install Docker on both the host and the agent.

So, first, install Docker on your CentOS 7 computer using the below command:

yum -y install docker

Once the installation is successful, begin the Docker service and attach that to your boot time with the following commands:

systemctl start docker

systemctl enable docker

Now, utilize the following command to verify if the Docker service installation on your Rancher host server was a success:

systemctl status docker

docker –version

If the installation is successful, you’d get an output specifying the docker version.

Step 2: Install Rancher Server

The next step is to install the Rancher server and run it. For doing so, you have to run your Rancher container on your host server.

Here, you need to install the Rancher server single container on your first host server. But before doing that, you have to create and specify a new directory as a Rancher DB volume.

Thus, execute the command below:

HOST_VOLUME=$HOME/rancher-data/mysql

mkdir -p $HOST_VOLUME

After that, install the Rancher server utilizing this command:

sudo docker run -d \

-v $HOST_VOLUME:/var/lib/mysql \

–restart=unless-stopped \

-p 8080:8080 \

rancher/server

Wait for some time and let the Rancher server installation finish. Once it’s finished, you will be capable of accessing the Rancher server via your browser.

Now, navigate to your browser’s address bar and type http://, followed by [your server IP address]:[your port number]. Unless you modify it yourself, your port number will be 8080.

Doing so will take you to the Rancher welcome page. It signifies that Rancher is up and running on port no. 8080 on your CentOS 7 system.

Step 3: Enable Local Authentication on your Rancher Server

After your Rancher server has begun running, there are numerous other important tasks left to execute. The first among those is to set up the Rancher access control. Doing so will let you manage users possessing access to your Rancher server.

Besides local authentication, Rancher harmonizes well with multiple access control providers such as Azure AD, SAML, Active Directory, etc.

For enabling Local Authentication on your Rancher server, launch your preferred browser and go to its URL bar and enter http:// followed by your server IP address and port number.

Next, pick ‘Access Control’ from the ‘ADMIN’ menu on the Rancher welcome page. Then, click ‘LOCAL’ and provide your login credentials.

Press the ‘Enable Local Auth’ button, and that’s it. You have successfully enabled Local Authentication.

Step 4: Add a New Host

Within Rancher, hosts are considered as the most rudimentary resource unit. Rancher also embodies them as any other Linux server (a Docker-installed physical/virtual server).

Here, you have to attach a new Ubuntu-installed host with a minimum of 2 GB RAM.

Establish connection to this new host via SSH utilizing this command:

ssh root@gost02

Next, install Docker on your host using the below command:

yum -y install docker

Upon the completion of the installation process, launch Docker and make it begin each time your system restarts:

systemctl status docker

docker –version

After the Docker installation is finished on your new host, we will add it to your Rancher as a host. For that, you need to launch the Rancher dashboard and go to ‘INFRASTRUCTURE’, followed by ‘Hosts’. Next, click ‘Add Host’ and enter the default Host Registration URL in the designated field. Once done, press the ‘Save’ button.

After that, you need to choose your Host type. Select ‘Custom’ and type your new host’s IP address. Also, don’t forget to copy the Docker command.

Next, launch your new host’s terminal and paste the command following:

sudo docker run -e CATTLE_AGENT_IP=”192.168.33.11″ –rm –privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.10 http://192.168.33.10:8080/v1/scripts/BCF2EFCA73A02954EBDF:1514678400000:OdRDdvnEUbV2hUMAFIS3oQxcTt4

Doing so will download the new Rancher agent container and run it. Upon flawless completion, you will receive an output confirming so.

Now, upon going back to the preceding page, click ‘Close’. With that, the new host has become a part of your Rancher server.

Step 5: Create a New Container for Testing

After everything is done, it’s best to check if the process went well. For that purpose, create a demo container, for instance, Ghost.

Doing so is easy. From the Rancher dashboard, go to ‘CATALOG’, followed by ‘Community Catalog.’ Next, in the search box, enter your container name (in this case, Ghost) and press the ‘View Details’ button. Assign a new name and description to your Ghost container and press ‘Launch.’ Once completed, you will see ‘Active’ written before your container name.

Your Ghost container is up and running now. Navigate to ‘INFRASTRUCTURE’ and press ‘Host.’ Here, you must ensure that your Ghost container runs on your new host server.

You can verify if your Ghost container installation was successful by going to your browser and typing your new host server IP address. It will take you to the default welcome page of the Ghost blog.

That’s all. Your Rancher installation on CentOS 7 is completed successfully.

Conclusion

As you can see, the process to install Rancher on CentOS 7 is nothing fancy. By simply following the steps mentioned above, you too can do it with ease. Every step has to be adhered to religiously. From installing Docker to your CentOS 7 to adding a new host – do everything systematically, and there’s nothing to fret about. Also, it’s crucial that you create a demo container to see everything is working fine. Here, we took Ghost as our demo. But, you’re free to pick any container that you desire.

It’s a known fact that Rancher has been a great solution to all K8s container deployment-related problems. Kubernetes, while being an amazing platform, is infamous for container deployment complexities. That’s why tools like Rancher become necessary, almost an essential part of the K8s world. Besides its efficiency, Rancher’s pure open-source facility and multi-cluster support have contributed to it being a maverick among similar platforms. If you too suffer from deployment issues regarding containers and containerized apps in Kubernetes, you shouldn’t misspend any more of your time. Utilize this guide, install Rancher on your local machine with ease. Good luck!

Read more
23Mar

How to Install Pip on CentOS 7?

March 23, 2022 admin centOS

Linux-based distribution CentOS 7 is preferred by many users. Most programmers prefer command-line OSes over GUIs, and CentOS 7 is one of the most popular command-line systems. Often, you will need to work in more than one language as a programmer. A good example of this is Python.

If you are a Python user, you must be aware about the various Python packages which you require and can easily download. The Python Package Index is the web repository of public Python packages, which is quite large. You might find downloading, maintaining, and updating these packages challenging.

What you need here is Pip- Pip Install packages. It is a system written in Python which installs and manages software packages for it. It makes the installation and management easy as it is connected to the online repository.

Packages contain every tool, file, and dependency you need to run a module, and modules are the heart of Python packages. Pip becomes even more useful as a result.

You may be wondering how to install pip on CentOS 7 if you are running a particular version of Python. Pip is simple to install, and a few commands will do it for you.

This guide contains commands to install, upgrade, downgrade, and use pip on your CentOS 7 system.

Installing pip On CentOS 7

There are two answers to the question of how to install pip on CentOS 7 as you can install it in two ways. One more thing you must know here. Pip is already installed for Python 2 series (version 2.79 or higher) and Python 3 series (version 3.4 or higher). If your system is running a version other than these, the commands mentioned below will be useful for you.

Before we dive into How to install pip on CentOS 7, you must check if your system has pip installed.

Following the command will help you check it.

python -m pip – – version

How to install pip on CentOS 7?

There are two methods to install pip on CentOS 7-

  • Using Curl and Python
  • Using Yum

Installing Pip With Curl and Python in the following steps-

  1. Go to the official repository and download the package with <strong> curl <strong> command.

curl “https://bootstrap.pypa.io/get-pip.py” -o “get-pip.py”

  1. Install pip using the command-

sudo python get-pip.py

  1. Confirm the installation-

pip -V

  1. Depending on your Python version, your pip version will vary but the output will look something like-

[sofija@localhost ~]$ pip -V

pip 20.0.2 from /usr/lib/python2.7/site-packages/pip (python 2.7)

Installing with Yum

You can also install pip on CentOS 7 with Yum. Follow the steps-

  1. Enable the epel repository with following

sudo yum install epel-release

  1. Now update your package-

sudo yum –y update

  1. Install pip with yum

sudo yum install python-pip

It was easy, wasn’t it? But it doesn’t end here.

Upgrading Pip On CentOS 7

Once you have installed pip on your CentOS 7 system, you may need to upgrade it with time. It is very simple and the following command will work for you.

python -m pip install -U pip

The command will do.

Downgrading Pip On CentOS 7

If an upgrade goes wrong or it limits a functionality, the need to downgrade the present version to an earlier one may arise. Execute-

python -m pip install pip==18.1

Using Pip On CentOS 7

So you’ve installed pip, but how can you use it? How do I install a package with it? You can use the following command to search for and install Python packages.

Search any package with-

pip search QUERY

Install package with-

pip search <package name>

Upgrade package with-

pip install – – upgrade <package name>

Remove a package with-

pip uninstall <package name>

Conclusion

Python is a powerful language with a lot of functionality. This language is used not only for designing programs or applications, but also for web development, software development, backend applications, etc.

That’s why programmers love it. In order to perform most of the functionality, modules must be found in packages on Python’s online repository. Installing these packages is easy with Pip.

Installing pip on CentOS 7 takes just a few seconds by using the commands below. Pip can be installed on various operating systems, including Ubuntu, Windows, and CentOS. It is not a complicated operation.

This guide is a comprehensive guide for installing, upgrading, downgrading and using pip for package installation. So, how to install pip on CentOS 7 is no longer a problem for you, right?

Read more
20May

How to Install Git on Centos, Ubuntu, and Windows?

May 20, 2021 admin centOS, Windows 10

Git is an immensely popular distributed version control system that helps users in managing all kinds of projects efficiently. More specifically, Git enables tracking of code changes, creating different code branches, and collaborating with a team of developers along with providing many more features. In fact, Git also hosts one of the most popular open-source projects, Linux Kernel.

If you are also interested in hosting your projects on Git repositories but have no idea how to install Git on your system, then you are at the right place. This guide is going to explain how to install Git on CentOS, Ubuntu, and Windows systems in a detailed manner.

Git Installation on CentOS 6.x/7.x

For installing Git on CentOS release version 6.x/7.x, you can use the ‘yum’ package manager. You need to run the following command to install Git:

$ sudo yum install Git

You may see a prompt on your screen to confirm the installation, you need to confirm by pressing ‘y’:

Is this ok [y/d/N]: y

Here is the end of the installation snippet of Git on CentOS 7 minimal setup that you will see on your system screen. This confirms that Git is installed on your CentOS 7, and please note that the dependencies installed along with Git can vary depending upon your OS version and installed packages.

Installed:

  git.x86_64 0:1.8.3.1-23.el7_8
Dependency Installed:
  perl.x86_64 4:5.16.3-297.el7 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Error.noarch 1:0.17020-2.el7
  perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7
  perl-Getopt-Long.noarch 0:2.40-3.el7 perl-Git.noarch 0:1.8.3.1-23.el7_8 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7
  perl-Pod-Escapes.noarch 1:1.04-297.el7 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-5.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-TermReadKey.x86_64 0:2.30-20.el7
  perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7
  perl-libs.x86_64 4:5.16.3-297.el7 perl-macros.x86_64 4:5.16.3-297.el7 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7
  perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 rsync.x86_64 0:3.1.2-10.el7
Complete!
$

Git Installation on CentOS 8.x

If you wish to install Git on CentOS version release 8.x or RHEL 8.x, you can use the DNF package manager. Install Git by running the following command:

$ sudo dnf install git

Now you may be prompted to confirm the installation. You will have to type ‘y’ and hit enter:

Is this ok [y/N]: y

This is the installation snippet that you will come across upon completion of the installation of Git on CentOS 8:

$ sudo dnf install git
CentOS-8 - AppStream 9.1 kB/s | 4.3 kB 00:00
CentOS-8 - AppStream 752 kB/s | 6.2 MB 00:08
CentOS-8 - Base 6.5 kB/s | 3.9 kB 00:00
CentOS-8 - Base 1.6 MB/s | 2.3 MB 00:01
CentOS-8 - Extras 3.5 kB/s | 1.5 kB 00:00
CentOS-8 - Extras 12 kB/s | 8.1 kB 00:00
Extra Packages for Enterprise Linux Modular 8 - x86_64 15 kB/s | 8.5 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 10 kB/s | 9.1 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 2.4 MB/s | 8.6 MB 00:03
Dependencies resolved.
==========================================================================================================================================================================
 Package Architecture Version Repository Size
==========================================================================================================================================================================
Installing:
 git x86_64 2.27.0-1.el8 AppStream 164 k
Installing dependencies:
 git-core x86_64 2.27.0-1.el8 AppStream 5.7 M
 git-core-doc noarch 2.27.0-1.el8 AppStream 2.5 M
 perl-Error noarch 1:0.17025-2.el8 AppStream 46 k
 perl-Git noarch 2.27.0-1.el8 AppStream 77 k
Transaction Summary
==========================================================================================================================================================================
Install 5 Packages
Total download size: 8.5 M
Installed size: 45 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): git-2.27.0-1.el8.x86_64.rpm 299 kB/s | 164 kB 00:00
(2/5): perl-Error-0.17025-2.el8.noarch.rpm 173 kB/s | 46 kB 00:00
(3/5): perl-Git-2.27.0-1.el8.noarch.rpm 182 kB/s | 77 kB 00:00
(4/5): git-core-doc-2.27.0-1.el8.noarch.rpm 813 kB/s | 2.5 MB 00:03
(5/5): git-core-2.27.0-1.el8.x86_64.rpm 431 kB/s | 5.7 MB 00:13
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 615 kB/s | 8.5 MB 00:14
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing : 1/1
  Installing : git-core-2.27.0-1.el8.x86_64 1/5
  Installing : git-core-doc-2.27.0-1.el8.noarch 2/5
  Installing : perl-Error-1:0.17025-2.el8.noarch 3/5
  Installing : perl-Git-2.27.0-1.el8.noarch 4/5
  Installing : git-2.27.0-1.el8.x86_64 5/5
  Running scriptlet: git-2.27.0-1.el8.x86_64 5/5
  Verifying : git-2.27.0-1.el8.x86_64 1/5
  Verifying : git-core-2.27.0-1.el8.x86_64 2/5
  Verifying : git-core-doc-2.27.0-1.el8.noarch 3/5
  Verifying : perl-Error-1:0.17025-2.el8.noarch 4/5
  Verifying : perl-Git-2.27.0-1.el8.noarch 5/5
Installed products updated.

Git Installation on Ubuntu

The easiest way to install Git on Ubuntu is by using an apt package manager. First of all, you need to update the apt package index by running the following command in the terminal:

$ sudo apt update

The terminal will show the following output:

Hit:1 http://in.archive.ubuntu.com/ubuntu groovy InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu groovy-updates InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu groovy-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu groovy-security InRelease [110 kB]
Fetched 110 kB in 1s (110 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done

All packages are up to date.

$

Then you will be required to use the following command for the installation of Git on your Ubuntu system:

$ sudo apt install git

You may see a prompt to confirm, which you can do by entering ‘Y’:

Do you want to continue? [Y/n] Y

Then you will see this installation snippet for Git installation on Ubuntu 20:

$ sudo apt install git

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following additional packages will be installed:

git-man liberror-perl

Suggested packages:

git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn

The following NEW packages will be installed:

git git-man liberror-perl

0 upgraded, three newly installed, 0 to remove, and 0 not upgraded.

Need to get 5,764 kB of archives.

After this operation, 41.2 MB of additional disk space will be used.

Do you want to continue? [Y/n] Y (Type Y and Hit Enter)

Get:1 http://in.archive.ubuntu.com/ubuntu groovy/main amd64 liberror-perl all 0.17029-1 [26.5 kB]

Git Installation on Windows

Git can be installed on Windows by downloading the applicable Windows binary installer, available on the official Git website.

On the official Git website, you will find 32-bit and 64-bit versions of Git, and you can download either of them depending on the architecture of your system. Generally, new systems support 64-bit architecture, and thus, the default downloader on the Git website should be apt for most users.

Follow the steps below to proceed with the installation process:

  • After you have downloaded the Git installer, you need to launch it. You will see the installation wizard on your system screen. On this installation wizard, you need to accept all the prompts that you may see in Windows’ User Access Control at the start of the installation. It will then ask for administrative access, which you need to accept so that the installation can be initiated.
  • If due to any administrative issues, the installation is unable to process, there is an alternative available. You can use the portable version of Git in this case. Whatever version of Git you are installing, you will need to accept the License Agreement and then click on the ‘Next’ option at the bottom of the window.
  • Now you are required to choose the installation path for Git, or you can also leave it to be the default path that is displayed on the dialog box. After specifying the desired installation path, you can click on the ‘Next’ button.
  • You will now come across a ‘Select Components’ dialog box on which you can choose the Git components that you need to install. You can leave this as default as all the essential components that you need are already selected. After selecting the required components, click on the ‘Next’ button.
  • After seeing the Start Menu shortcut options, click Next.
  • You will be asked to choose the default editor that will be used by Git. You can select one among the available options, such as Notepad, in the drop-down list. After choosing the default editor, click Next to continue.
  • Then you will see the dialog box for naming the initial branch for the new repositories. You can leave it as it is and “Let Git decide,” or you can name it yourself in the second option and when done, click on the ‘Next’ button.
  • By default, Git will be added to the Windows PATH variable to be accessible for other programs like Command Prompt, etc., and you can choose the 1st option if you would like to use Git from Git Bash only. Once you have selected your desired option, click the ‘Next’ button to continue.
  • Network-related actions for Git like push and pull requests require Secure Shell or SSH executable, and on this dialog box, you are given a choice to select the SSH executable you prefer. The default option selected is “Use OpenSSH,” and it should be left as it is except if you specifically need TortoisePlink. To continue with the installation, click the ‘Next’ button.
  • You can choose the default selected option for choosing the HTTPS transport backend, “Use the OpenSSL library”. The other option is the one that comes with Windows; you can choose whichever you want and then click on Next.
  • You need to confirm the commit style next. It should be noted that Windows and Linux/Unix systems interpret end-of-line differently. So, for making the code compatible between different development platforms, Git must be made aware of how the code file has an end-of-line character specified and whether it is required to be switched to another style. The default option selected here is ideal as it enables all the switching and conversion to happen in the background by Git, and if you are unsure what option you would like to choose, then you can consult your Git code administrator. When done, click on the ‘Next’ button to continue further.
  • The next dialog box that you see will ask you to configure the terminal emulator, which enables you to either have a BASH-like environment or Windows Command Prompt as the default console. You can choose either of these options as they both work nicely, and after selecting one of them, you can click Next.
  • Now you will be asked to specify the default “git bull” behavior, and in this case, you should go with the default option selected unless you have certain specifications. When selected, click on the ‘Next’ button to move on.
  • The credential manager is designed to store your private information, such as your passwords and keys that you require for logging in to various remote Git repositories. The first option should also be selected, which is the default because Git Credential Manager has been deprecated. You need to click on the ‘Next’ button to continue.
  • Now you will be required to select some additional options such as file system caching and symbolic links. You can click on Next after selecting the desired options.
  • The experimental configuration dialog box is meant for you to enable features on Git that have not been fully developed and tested yet. You can leave the options unchecked except if you need any of those. At last, click on the ‘Install button at the bottom of the dialog box so that the installation process can begin with your preferred selections.
  • Now you will observe that the installation of Git on your Windows system begins, and you have to wait for it to be completed.
  • After the installation is complete, a final dialog will appear that will enable you to launch Git Bash.
  • In the future, you can launch Git Bash or Git GUI by clicking on its icon in your Windows Start Menu. Git Bash is a similar command line (CLI) that Linux offers, and all Git commands are supported by it. Now, you can verify the Git version by launching the Git Bash and following the steps mentioned in the next section.

Verifying Git

In order to verify your Git installation and check if its the right version that you have installed, you need the run the following command on the Git Bash in Windows:

$ Git --version

Output:

git version 2.27.0
$

Conclusion

The purpose of this guide is to define the individual steps required to install Git on different operating systems, namely CentOS, Ubuntu, and Windows. If you follow the steps mentioned within the article properly, you will be able to install Git with ease. If you have any issues with installing Git or using Git, you can check out the resources available on their official website.

Read more
14Feb

How to Install Docker on CentOS?

February 14, 2021 admin centOS, Docker

Docker is an application that delivers software in certain packages called containers, which are highly convenient and resource-friendly units dependent on the host OS. Docker uses operating-system-level virtualization to run software applications in a container.

In order to install Docker on CentOS, there are 2 methods to choose from:

  • The first method is to install it on an existing application of CentOS, and
  • The second method is to spin up a server using the Docker Machine tool and then run the auto installation.

We will only discuss the first method here – and save the second method for some other article – with a detailed step-by-step guide. It will help anyone looking to install Docker on CentOS. The process of using Docker will also be mentioned in detail.

Prerequisites

Before moving on to the tutorial, there are certain things that you need to install Docker on CentOS successfully. These are:

  • A 64-bit version of CentOS 7 Droplet or CentOS 8. Keep in mind that archived versions may not work because they are not supported or tested.
  • Usually, the ‘centos-extras’ repository is enabled by default, but in case you have disabled it, you have to make sure that it is re-enabled.
  • The ‘overlay2’ storage driver.
  • You need to uninstall older versions of Docker, if any. The old versions were generally called ‘docker’ or ‘docker-engine’.

Note: Use the following code to uninstall old versions of Docker:

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

How to Install Docker on CentOS?

In this section, you will be guided step-by-step on how to install the latest version of Docker from the official Docker repository.

Step 1: Docker Installation

Update the package database by running the following command:

$ sudo yum check-update

The following command will download and install the latest version of Docker from the official Docker repository:

$ curl -fsSL https://get.docker.com/ | sh

When the installation is completed, you need to run the following command to start the Docker daemon:

$ sudo systemctl start docker

Run this command to verify that Docker is running:

$ sudo docker run hello-world

The above command will download a test image and will run the same in a container. The container will print a message “Hello World”, and exit when it runs.

When you pulled the image from Docker Hub, you must have received the following output:

Output

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

Now, you need to run the following command so that Docker starts after every reboot:

$ sudo systemctl enable docker

Now since you have the Docker service (daemon), you also get the docker command-line utility. Using the same will be further explained in detail.

Step 2: Run Docker Command without Sudo

For running the ‘docker’ command, it requires the prefix ‘sudo’ as it requires root privileges. However, you can let go of the ‘sudo’ prefix if you run the command in the docker group. The installation of Docker also creates the Docker group by itself. To be able to do that, you need to follow the given steps:

Add your username to the docker group by running the following command:

$ sudo usermod -aG docker $(whoami)

Now, in order to allow this change, you have to log out of the Droplet and then log in as the same user. You can also add another user to the Docker group even if you are not logged in as that user by running this command:

$ sudo usermod -aG docker username

Therefore, now you can easily run the ‘docker’ command as a user in the Docker group without the use of the prefix ‘sudo’. The rest of this tutorial will assume that you have made this change. If you have chosen not to, then add ‘sudo’ to every command.

Step 3: Running the Docker Command

Since Docker is now installed and working fine, you can start running the docker command-line utility. Let’s take a look at how you can do it:

Start with running the following command:

$ docker [option] [command] [arguments]

You can view all the available subcommands by typing:

$ docker

The full list of subcommands available in Docker 1.11.1 is given below:

Output

    attach    Attach to a running container
    build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    cp        Copy files/folders between a container and the local filesystem
    create    Create a new container
    diff      Inspect changes on a container's filesystem
    events    Get real time events from the server
    exec      Run a command in a running container
    export    Export a container's filesystem as a tar archive
    history   Show the history of an image
    images    List images
    import    Import the contents from a tarball to create a filesystem image
    info      Display system-wide information
    inspect   Return low-level information on a container or image
    kill      Kill a running container
    load      Load an image from a tar archive or STDIN
    login     Log in to a Docker registry
    logout    Log out from a Docker registry
    logs      Fetch the logs of a container
    network   Manage Docker networks
    pause     Pause all processes within a container
    port      List port mappings or a specific mapping for the CONTAINER
    ps        List containers
    pull      Pull an image or a repository from a registry
    push      Push an image or a repository to a registry
    rename    Rename a container
    restart   Restart a container
    rm        Remove one or more containers
    rmi       Remove one or more images
    run       Run a command in a new container
    save      Save one or more images to a tar archive
    search    Search the Docker Hub for images
    start     Start one or more stopped containers
    stats     Display a live stream of container(s) resource usage statistics 
    stop      Stop a running container
    tag       Tag an image into a repository
    top       Display the running processes of a container
    unpause   Unpause all processes within a container
    update    Update configuration of one or more containers
    version   Show the Docker version information
    volume    Manage Docker volumes
    wait      Block until a container stops, then print its exit code

You can view the available switches to a certain command by running this command:

$ docker docker-subcommand --help

If you want to see the system-wide information on Docker, run this command:

$ docker info

Step 4: Docker Images

Docker Images pull images from Docker Hub by default, which, in turn, runs Docker containers. Any user is allowed to create and host their own Docker images on Docker Hub.

In this article, we discussed how to pull a Docker image when we verified that Docker is running. We pulled an image titled ‘hello-world’ from Docker Hub, which is a part of the Docker project.

Docker also allows the users to search for images among the Docker Hub collection and a user needs to type the following command to search, for example, for the CentOS image:

$ docker search centos

Then you will observe a listing of all of the images whose name matches with your search string. The output will look somewhat like this:

Output

NAME DESCRIPTION

centos The official build of CentOS.
jdeathe/centos-ssh CentOS-6 6 . 7 x86_64 / CentOS-7 
jdeathe/centos-ssh-apache-php CentOS-6 6.7 x86_64 / Apache / PHP / P
milion12/centos-supervisor Base CentOS-7 with supervisord launche
nimmis/java-centos This is docker images of CentOS 7 with 
torusware/speedus-centos Always updated official CentOS docker 
nickistre/centos-lamp LAMP on centos setup

After choosing the image you want to use, you can use the ‘pull’ subcommand and download it on your system by typing this:

$ docker pull centos

Then you can run the image that you have downloaded by using the ‘run’ subcommand like this:

$ docker run centos

If you wish to view the images that you have downloaded on your computer, then you can run the following command:

$ docker images

The output should look something like this:

Output

[secondary_lable Output]

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

centos                      latest              778a53015523        5 weeks ago         196.7 MB

hello-world               latest              94df4f0ce8a4          2 weeks ago         967 B

Step 5: Run a Docker Container

We ran the ‘hello-world’ container earlier in this tutorial. That container was the type of container that first runs and then exits after giving an output message.

Containers can do so much more than that as they are similar to virtual machines. Now, let us take a look at how to run a container with the CentOS image that we just downloaded on our computer. You can use the combination of the -i and -t switches for having interactive shell access into the container:

$ docker run -it centos

The output that you will receive will be like this:

Output

[root@59839a1b7de2 /]#

After this, you are enabled to run any command you want in the container.

Conclusion

This step-by-step guide will help you get started with Docker by providing you the basic knowledge of the same so that you may develop further on that by putting your knowledge to practical use.

That sums up this brief introductory tutorial on installing and using Docker on CentOS. The containerization platform can be used for much more useful purposes as it is very resource-friendly. You are welcome to read more about Docker on the official website to get more out of the powerful containerization platform.

Read more
corporate-one-light
+1 800 622 22 02
info@scapeindustries.com

Company

Working hours

Mon-Tue

9:00 – 18:00

Friday

9:00 – 18:00

Sat-Sun

Closed

Contacts

3 New Orchard Road
Armonk, New York 10504-1522
United States
915-599-1900

© 2021 Kuberty.io by Kuberty.io