In this article I’ll show you how to install docker on a CentOS7 machine and make it ready for your future docking deployments. If you are not familiar with containers you should know that this technology allows you to create multiple user space instances on a Linux machine. Simply put, you can run multiple applications that have their own environment in terms of processes, user space and file system (hence the “container” name). Each container is isolated from others. The only thing that’s shared between containers is the Linux kernel since containers run on top of the OS. Containers have a lower resource footprint than Virtual Machines since multiple containers can run on a single server. By comparison, with VMs you need to spawn multiple servers that have their own Operating System on top of which you run applications. Since each container is isolated you can run multiple applications that listen on the same port on a single server.
To install docker on CentOS7 run the yum install docker command:
You can verify the status of the docker service by typing systemctl status docker.service:
As you can see, the docker service is stopped right now so we need to start it by typing systemctl start docker.service. You can then verify again the status of the service to make sure it has successfully started:
What’s left to do is to enable the automatic startup of the docker service. To achieve this result use the systemctl enable docker command:
As you can see form the image, a symlink is created from the multi-user.target.wants directory to the location of the docker service. Because our machine will run by default in multi-user mode, the docker service is added to this location. You can verify the default target by typing systemctl get-default or by checking the contents of the /etc/systemd/system/default.target file:
Now execute docker run hello-world to make sure that the installation has been completed successfully:
To view system-wide docker information type docker info. You can also verify docker version with the docker version command:
That’s about it for this first docker article, once you have everything installed and configured, you can proceed further with docker containers and images. Stay tuned for the following articles from IT training day.