Docker Series Part 1: Simple Introduction

Containers have existed long before Docker came into the picture.  Let us see what is LXC(Linux Containers)

Linux users easily create and manage system or application containers. The goal of LXC is to create an environment as close as possible to a standard Linux installation but without the need for a separate kernel.

This is perfect for isolating applications and containerizing them; this is useful as the other processes can’t access resources in any other container. Let’s see what the Docker team says,

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.

In much simpler terms, they provide a Virtual Machine like isolated environment with a few other benefits. But while Docker is more of application container, LXC is more of a OS container.  I suggest this article for an introduction to LXC.

Let’s get started with using Docker. First install Docker Engine following the instructions here.

Let’s run our first container.

docker run -it ubuntu

This will put you in a Ubuntu container. You will have the same experience whether you are on Linux, Mac OS or Windows. You have to keep in mind that Docker containers are not VMs. Containers are ephemeral.

If you install any software or create/modify any files, you will have to create a new image for these changes to persist. For this, you will have to commit your current changes in a new Docker image.

➜  ~ docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                   PORTS               NAMES
89d5116abd2e        alpine                "sh"                     5 seconds ago       Exited (0) 2 seconds ago                       vigilant_kilby
➜  ~ docker commit 89d5116abd2e mynewimage

The docker commit will take the old container’s ID and the name of the new image as arguments.

I guess this is enough to get started. You can check more pre-built public images at the Docker Hub or the Docker Store.

Leave a Reply

Your email address will not be published. Required fields are marked *