Introduction to Docker
Many of the ideas from virtual containers can be linked to the historical use of their physical counterparts. Traditionally, containers have allowed us to isolate, store and ship different types of items in a single body (such as a transport ship, warehouse, etc). In computing, containerization allows us to separate and run multiple virtual operating systems on a single host machine. Docker provides features that make creating and interacting with these virtual systems simple.
Containerization vs Virtual Machines
Readers familiar with virtual machines might notice that containers seem to be filling a similar role – that is correct! However, containers have a key advantage that makes them a better choice in most situations. Virtual machines emulate the entire virtual operating system (including a virtual kernel) using a software called a hypervisor. Docker on the other hand uses, a background process (a daemon) that is able to simulate the operating system of the container using only the kernel of the host operating system. This significantly reduces startup time, CPU memory requirements and computational speed, which can save the user a lot of money (especially when using a cloud service provider).
Benefits and Use Cases of Docker
Using Docker, the most popular container system, has many benefits due to the large amount of features and rich ecosystem that it provides. Some of its most notable features, for which future posts will go into more detail, are listed here:
- When developing software, it can be hard to ensure that the environment and dependencies on the developers machine will be the same as those on a remote server. Software can be loaded into a container and shipped to the server, ensuring that it behaves as it did on the local machine.
- Docker containers provide various ways to interface with each other, allowing the formation of container networks.
- A large community has formed around Docker. New Docker containers can be setup quickly, using the container blueprints (more commonly known as “Docker Images”) of other users. Thanks to DockerHub, many databases, monitoring tools, and other pieces of complex software can be initialized instantly.
- Many tools and cloud providers offer Docker integrations, as it is the industry standard.
An installer for Windows and Mac can be installed from Docker Hub. If you are on a Linux machine, you will need to use the command line. Here is how to install Docker on Ubuntu:
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 $(lsb_release -cs) stable" sudo apt-get update sudo apt-get install -y docker-ce sudo service docker start sudo docker run hello-world
The previous code will install Docker and then start the daemon. Once Docker is up and running, it will try to run a “hello-world” container on your machine – if Docker does not find an “Image” with that name on your computer, it will attempt to download it from DockerHub. If everything worked, you should see a “hello world” prompt. In the next part of the series, you will learn more about Dockers versatile command line interface and how to configure your own Docker containers from scratch .