Docker is a platform that automates the deployment of software inside the container, so they are able to build and run applications anywhere as a lightweight container.So, it provides another abstraction layer. The best thing of Docker is, that allow different containers to run a single Linux machine, which improves performance and time.
Docker is based on containers. A container is a software in a complete filesystem that has inside it the tools, the libraries, the code and everything you need to run that software. This approach improves the way code runs, making sure that software works on every machine, regardless its environment.
The difference between virtual machines and containers is that the former share the kernel with other containers, which save a lot of space in hard drive. Also, containers are not linked to a specific infrastructure, they run on the cloud or on any type of computer.
Another important term for Docker is Docker images. An image has the OS and the applications that are pre-installed. You can’t run a container without the Docker image. There are lots of images with a variety of OS and software out there. You can find them at https://hub.docker.com
Why Use Docker
Docker has three big features which make it a preferred choice for programmers and system admins to use.
First of all, it is open source and its container is based on open source licenses allowing containers to run on the majority of all Microsoft and Linux operating systems.
Second, it is very secure, because container cannot harm each other. They isolate applications from each other while providing another layer which protects the application.
The third feature is its efficiency. It is lightweight because all containers share the same OS, and this makes the use of RAM more efficient. Images also share common files.
How to Install and Use Docker in Linux
In this tutorial, I’m going to install Docker in my Ubuntu 14.04. By the way, I’m a fan of LTS.
To install Docker run this command in Terminal:
sudo apt-get install -y docker.io
After you have installed Docker, you can start it with the following command:
systemctl start docker
Now you have learned how to install and open Docker. It is time to learn how to work with the basic commands of it.
If you want to create a new container, firstly you should search a base image with the following command. For example, I want to search for Ubuntu.
docker search ubuntu
You can see all Ubuntu images after you have executed this command.
Then install this image in your system with this command.
docker pull ubuntu
To seel all downloaded images, run:
Now it’s a special moment, it’s the time to create a container and start it. We can do that with the following command:
docker run -i -t ubuntu:14.04 /bin/bash
You have just created and started a container based on Ubuntu 14.04 and have run the
/bin/bash command inside the container.
exit to stop the container and to leave it.
This is just a warm up for Docker in Linux. Soon I will write more in-depth tutorials that will cover Docker in Linux and especially in Ubuntu.