January 22, 2020
January 22, 2020
Docker’s concept and technology are very widespread today. Many sysadmins use it for their work because of the many advantages they provide when handling containers in Linux. That’s why today we’ll show you how to install Docker on CentOS7, and then how to install Docker Compose to empower your VPS even more!
Docker is loved above all for the deployment of images containing applications or services that we want to install in our network. In addition to all this, it is an open source project that facilitates the understanding of its operation and even adaptability in the company.
Docker is an open source technology that manages and automates the deployment of applications through a container. These containers are distributed through images that contain everything necessary to run an application. For example, there are images from WordPress, 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 the 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, starting to use this utility is easy! Let’s learn how to Install Docker on CentOS 7!
Installing Docker on CentOS 7 is simple. To do this, it is necessary to connect to our server using SSH. Check out our PuTTY tutorial if you’re having issues.
Then, we have to install a series of packages prior to installing Docker. We need to be the root user and run the following line in the command line:
yum install -y yum-utils device-mapper-persistent-data lvm2
The easiest and safest way to complete the process is through Docker’s official repositories. To do this, it is necessary to execute this line:
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
After that, we can install Docker on CentOS 7 by running the following command:
yum install docker-ce
We now know how to install Docker on CentOS. But it’s not running yet! To enable and start docker, execute the following commands:
systemctl enable docker
systemctl start docker
Finally, we can check the status of the service to check that everything has gone well:
systemctl status docker
In the output we should see a green line indicating that Docker is up and running.
First, let us run Docker’s “Hello World” command as a start. To do it, we need to run the following command:
docker run hello-world
This test image is the one that Docker recommends checking every time you reinstall the utility.
We can verify all the images we have in our system with this command:
Or search the Docker repository for an available image with the search command.
docker search [search]
For example, we can search for an image related to CentOS 7.
docker search centos7
And if we want to download it, we can do it with the following command:
docker pull [image_name]
Finally, to execute it we will use the run command. We will be able to call the image by its ID or directly by its name.
docker run -t -i [image_id or image_name]
The option -i means that we will make the image interactive, while the option -t means we will have access to a terminal and can simulate one.
To exit from an image, we need to press CTRL+D.
Docker Compose is a utility that allows us to display images in Docker. It was created because many programs require other services to run. For example, with WordPress or another CMS, we require, first of all, a functional web server, and the image of a database manager and finally the image of the application.
We would have to deploy them one by one and configure them. With Docker Composer we can define everything in a 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 we do not have curl installed, we can do it using the following command:
yum install curl
Then we have to assign execution permissions to the Docker Compose binary:
chmod +x /usr/local/bin/docker-compose
And now, to ensure there are no problems when using the utility in the terminal, we 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:
And we’re ready to use both Docker, and Docker Compose.
Today Docker is a very widely used utility. The deployment of applications in the form of containers saves us from compatibility issues. In addition, Docker facilitates the installation and maintenance of existing containers. On the other hand, if we add a tool such as Compose to Docker’s technology, productivity and efficiency would be improved even further.
Knowing about Docker is very important nowadays, that is why we recommend you to visit the project’s website and read more about it. Happy learning!
May 15 2020
thanks a lot the best guide on the internet