fbpx Installing and configuring Docker on CentOS
24/7/365 Support

Installing and configuring Docker on CentOS

Traditional virtualization technologies provide hardware virtualization, which means they create a complete hardware environment so each virtual machine (VM) needs a complete operating system to run it. Therefore they have some major drawbacks because they are heavyweight and produce a lot of overhead while running. This is where the open-source Docker containerization engine offers an attractive alternative. It can help you build applications in Linux containers, thus providing application virtualization.

This means that you can bundle any Linux program of choice with all its dependencies and its own environment and then share it or run multiple instances of it, each as a completely isolated and separated process on any modern Linux kernel, thus providing native runtime performance, easy portability, and high scalability. Here, in this process, we will show you how to install and configure Docker on your CentOS 7 server.

To Start With: What Do You Need?

To complete this process, you will require a working installation of the CentOS 7 operating system with root privileges, a console-based text editor of your choice, and a connection to the Internet in order to download additional rpm packages and a test Docker image.

The Process

While Docker is available as a package in the official CentOS 7 repository, we will use the official Docker repository to install it on our system instead.

  1. To begin, log in as root and update your YUM packages before downloading and executing the official Docker Linux installation script using the following command:
    yum update && curl -sSL https://get.docker.com/ | sh
  2. Next, enable Docker at boot time before starting the Docker daemon (the first time you start, it will take a while):
    systemctl enable docker && systemctl start docker
  3. Finally, after starting Docker you can verify that it’s working by typing:
    docker run hello-world

How Does It Work?

When installing any software on CentOS 7, most of the time it is very good advice to use the packages available in your official CentOS repository instead of downloading and installing from third-party locations. Hereby installing Docker using the official Docker repository instead, we made an exception. We did this because Docker is a very young project and is evolving fast, and it keeps changing a lot. While you can use Docker for running every Linux application, including critical web servers or programs dealing with confidential data, bugs found or introduced into the Docker program can have severe security consequences. By using the official Docker repository, we make sure we always get the latest updates and patches available as fast as possible right from the developers of this fast-moving project. So anytime you type yum update in the future, your package manager will automatically query and check the Docker repos to see if there is a new version of Docker available for you.

So what did we learn from this experience?

We started this process by logging into our server as root and updated the YUM package’s database. Then we used a command to download and execute the official Docker installation script from https://get.docker.com/ in one step. What this script does is add the official Docker repository to the YUM package manager as a new package source and then automatically install Docker in the background. Afterwards, we enabled the Docker service at boot-time and started it by using systemd. Finally, to test our installation, we issued the command docker run hello-world, which downloads a special image from the official Docker registry to test our installation. If everything went fine, you should see the following success message (output truncated):
Hello from Docker

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

 

Help Category:

What Our Clients Say