How to install Docker on CentOS 7 + Docker Compose

The concept and technology of Docker are well known today. Many sysadmins use this tool for work due to the many advantages it provides when managing containers on Linux. That’s why today we’re going to show you how to install Docker on CentOS 7, and then how to install Docker Compose to further empower your !

Docker is highly appreciated above all for the deployment of images that contain applications or services that we commonly want to install on our network. In addition to all this, it is an open source project that makes it easy to understand how it works and even adapt it as needed.

Understanding what is Docker and its containers

is an open source technology that manages and automates application deployment through a container. These containers are distributed through images that contain everything needed to run an application. For example, there are images of , Nginx, MariaDB, and many other services or applications.

The main advantage of using Docker is that we can “install” services or applications on many systems, regardless of hardware. For example, we can make an image of our application, and it can run on any computer that has Docker installed. All this regardless of the operating system or hardware in question.

Best of all, getting started with this tool is super easy! Let’s learn how to install Docker on CentOS 7!

How to install Docker on CentOS 7

Installing Docker on CentOS 7 is simple. To do so, you need to connect to your server using SSH. Consult our if you have problems with this step.

See also  How to add Adsense to a WordPress site

ssh your-user@your-server

Next, we have to install a number of packages before installing Docker. We need to be the root user and run the following line on the command line:

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

The easiest and safest way to complete the process is through the official Docker repositories. To do this, you need to run this command line:

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

After this, we can install Docker on CentOS 7 by running the following command:

yum install docker-ce

Now you know how to install Docker on CentOS. But it’s still not running! To enable and start Docker, run the following commands:

systemctl enable docker systemctl start docker

Finally, you can check the status of the service to check that everything went well:

systemctl status docker

As a result we should see a green line indicating that Docker is up and running.

Basic Docker applications

First, let’s start with the Docker “Hello World” command. For this you need to execute the following command:

docker run hello world

This test image is the one that Docker recommends checking each time the tool is reinstalled.

You can check all the images you have on your system with this command:

docker images

Or search the Docker repository for an available image with the search command.

docker search

For example, you can search for a CentOS 7 related image like so:

docker search centos7

And if you want to download an image, you can do it with the following command:

docker pull

Finally, to run the image use the run command. You can call the image by its ID or directly by its name.

See also  What is and how to use the wget command + 12 examples

docker run -t -i

The option -Yo means that you will make the image interactive, while the option -t it means that you will have access to a terminal and you can simulate one.

To exit an image, you must press CTRL+D.

How to install Docker Compose on CentOS 7

Docker Compose is a utility that allows us to display images in Docker. It was created because many programs require extra services to run. For example, with WordPress or another CMS, we first require a functional web server and database administrator image, and finally the application image.

We would have to deploy them one by one and configure them. With Docker Composer we can define everything in a single file, with all the images dependent on the main one and load them normally.

To install Docker Compose on CentOS 7, we need to run this command:

curl -L “https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin /docker-compose

In case you don’t have curl installed, you can install it using the following command:

yum install curl

Then you have to assign execute permissions to the Docker Compose binary:

chmod +x /usr/local/bin/docker-compose

And now, to ensure that there are no problems using the tool in the terminal, you will have to make a symbolic link to the system:

ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Finally, check the installed version:

docker-compose –version

And you will be ready to use Docker and Docker Compose.

conclusion

Today Docker is a widely used tool. The implementation of applications in the form of containers saves us from compatibility problems. Additionally, Docker makes it easy to install and maintain existing containers. On the other hand, if you add a tool like Compose to Docker’s technology, productivity and efficiency will improve even more.

See also  IMAP or POP3: definition, differences and SMTP function

Knowing everything about installing Docker on CentOS and about the tool itself is very important nowadays, that’s why we recommend you to visit the project’s website and read more about it. Happy learning!

Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

Loading Facebook Comments ...
Loading Disqus Comments ...