Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.
- official docker website
Why is it so cool?
I bet you already said or heard somebody at work
say "it worked on my computer..." whenever some piece of code went in production and a bug was found.
Docker is cool because it makes your application work on any operating system and makes sure it will work the same exact way in production as in development/test mode. Moreover, it simplifies considerably the setup of the application on a new environment.
Setup Docker on CentOS 7
Requisites: 64-bit version Centos7
Make a full system update:
$ sudo yum update
Centos provides an old version of Docker with the package name "docker". Install the new one called docker-engine using yum:
$ sudo yum -y install docker-engine
This command will install both the docker daemon and the docker client.
$ sudo systemctl start docker
To test whether the installation was successfully try running a centos docker container. In order to do this, pull the image from the Docker Hub repository
$ docker pull centos:latest
then run the image with the command options -t -i that will allow us to run any shell command inside the container after initiating it. In our case we will run the shell command /bin/bash in order to keep the ssh session open:
$ docker run -i -t --rm centos:latest /bin/bash
The --rm options will remove the container after it has been killed.