This time we will try to discuss what is Docker Container. One of the most popular tools loved by developers.
What is Docker?
Docker is a tool or tool designed to make it easier for developers to create applications that are stored in a container. With a container system, developers will be easier to package applications in the operating system, including all the data libraries in it. Next, the developer will package all packages in the form of images. These images will later be run by other developers easily.
Suppose that we install the Ubuntu OS, then we install Nginx as a web server, MariaDB as the MySQL server. Then we install WordPress in it. The process will certainly be very long and requires a decent server knowledge. Well, with a container system, everything we install will be packaged in the form of Image. This image can later be shared with other developers or can be used alone. So for the next, it is no longer necessary to install Ubuntu OS, nginx web servers, MariaDB and Wordpress. Everything will immediately be run using the image that we have created, which for example, we named Wordpress Image.
Docker looks like a virtual system, but it's not. The Docker container uses the same kernel as the host. The operating system that is run is very minimal and saving disk space. For example for the nginx image with Alpine Linux, it only requires 84MB of storage space. Because the Docker runs on the same kernel as the host, the Docker can be run on a virtual machine or VPS. And more encouraging, Docker is open source so that it can be used and developed for free.
Docker provides a sharp image built by developers around the world. You can access the Docker Hub site to get images with various categories. If you are a docker developer, you can share the image of your software packaging by registering at Docker hub for free.
Installing a Docker is relatively easy. Docker supports multiple Operating Systems, so developers don't have to bother changing the Operating System. Here is how to install Docker on several Operating Systems.
Redhat or Centos
To install Docker on a Redhat-based Operating System, for example, Centos. Prepare a machine that has Centos Fresh installed, then type the following command.
yum -y update yum remove docker docker-common docker-selinux docker-engine yum -y install yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum -y install docker-ce systemctl start docker systemctl enable docker
The above command will install the latest Docker, run, and set up so that Docker starts automatically when the machine restarts. This command was successful when we tried the Centos 7.8 Operating System.
Ubuntu or Debian
Prepare the machine that has already installed Fresh Ubuntu, then log in with the root user. When we try this command, we use the Ubuntu OS 18.04.
apt update apt install -y apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" sudo apt update sudo apt -y install docker-ce sudo systemctl start docker sudo systemctl enable docker
To install the docker on Windows 10 is very easy. You only need to download the installation package, then install it on your windows. During this installation, we use the Windows 10 Pro 64 bit system.
- Download Docker MSI on Docker page.
- Double click on the file that was successfully downloaded.
- Follow all Installation steps
- Click "Finish" to complete the installation
- Finish, and Docker is ready to switch on.
Check Docker Installation
To test whether the Docker is installed correctly, please type the following code.
If all the information about your Docker has appeared, then the Docker is ready to use.
Now we will try running the nginx image on your Docker. Type the following command on your system.
Before docker is run, we try to create a folder for html.
Then run docker.
docker run -d --name nginx \\ -v /home/web:/usr/share/nginx/html:ro \\ nginx
The above command will run the nginx web server with the name nginx container. The -v or --volume option will mount everything in path /usr/share/nginx/html in the container to path /home/web on your host. So, if you want to upload html files, you can save the html in directory /home/web on your system.
Well, it's easy, with the Docker. The nginx installation process is usually long, with the docker only requiring a few lines. In the next article, we will try to install a number of applications with fairly complex configurations.
Thank you, hopefully it will be useful.