Docker what is it and how to get started
Containers are one of the most observed technologies lately, with high performance, great functionalities and higher scalability than VMs; they promise much but they’re still a somewhat untested technology. Yet times are coming close and many brave societies are starting to bet on this innovation to get an edge over competitors.
What are containers?
The first thing to understand is the concept of container. Before starting I suggest you not to read if you’re not comfortable with virtualization. That said containers are similar to Virtual Machines but how are they different? The principal difference is that Virtual Machines are completely abstracted, the full stack starting from BIOS/UEFI up to the kernel is abstracted and different for each VM. Containers on the other side take advantage of the existing architecture and virtualize thereafter. Without the need of abstracting the hardware much less resources are used hence containers are more lightweight than VMs. Containers tend also to share as much as possible with each other (posing security problems) whilst VMs tend to lock the resources and share as less as possible.
Docker and containers
Now that you have an idea of what containers are let’s speak a bit about the leader solution in the field: Docker. Docker is the project that created all this enthusiasm about containers, but it is not the first solution to appear. Long before Docker there were LXC containers (on which Docker was based until it moved to runC). Another alternative is BSD Jails. As you can see there were many approaches long before Docker. Then what is the reason behind its success? Much lies behind the architecture itself, let’s take a look.
The Big Picture
Much like VMs are backed by a Hypervisor, Docker Containers are backed by the Docker Engine. Before we start talking about containers, let’s take a look at Docker Images and Docker Registries. A container is much like a VM, it has its state, its services and its processes, however when you run a VM you always start from a base image, Docker Images are mostly the same, they are composed of an Operating System and optionally pre-installed software. These images are read-only templates and can be pulled or pushed (much like Git) to a registry called Docker Registry (much like Vagrant, you’ll see it later). Once you have your image you can spawn an instance from that, that instance is a container. It’s not that different from Virtual Machines right? However the Git-like structure allow you to base new images on changes you made with pretty much a few commands.
Before starting ensure you have a 64-bit host and a kernel version > 3.10. You can also install Docker on Windows > 7 (10 not yet supported). The procedure thereafter depends on your operating system. You can find installation instructions on the official site. In most cases you can just do (you will probably need elevated privileges):
curl -sSL https://get.docker.com/ | sh
Done? Let’s start the service
sudo service docker start # For SysVinit / Upstart sudo systemctl start docker # For systemD
After you’ve done that what’s next? Getting an image is the next step, but how can we find images? You can search them through hub.docker.com or use the CLI:
docker search IMAGE_NAME
Once you’ve decided which image you want, use:
docker pull IMAGE_OWNER/IMAGE_NAME:IMAGE_TAG
IMAGE_TAG is as you might imagine a sort of version for the image. While IMAGE_OWNER is the owner who submitted that particular image (much like Vagrant). Now that you’ve got the image you can make it do anything you want! Let’ start by creating a container:
docker run -t -i IMAGE_OWNER/IMAGE_NAME:IMAGE_TAG /bin/bash
Congratulations! You are now inside the container’s shell! This is great, however many folks out there will want something more classical. If what you search is hello, world!, Docker’s got that too.
docker run hello-world
Now that you have understood what containers look like and what Docker can do for you, you will probably feel like it’s a shame or it’s a great thing. But there’s much much more to Docker than you might imagine. Next articles will cover Docker basics, Kubernetes and operating systems to manage a container fleet.
Latest posts by mark (see all)
- 2020 A year in review for Marksei.com - 30 December 2020
- Red Hat pulls the kill switch on CentOS - 16 December 2020
- OpenZFS 2.0 released: unified ZFS for Linux and BSD - 9 December 2020