Skip to content

Containers Overview

Introduction

You wanted to run your application on different computing environments. It may be your laptop, test environment, staging environment or production environment.

So, when you run it on these different environments, will your application work reliably ?

What if some underlying software changes ? What if the security policies are different ? or something else changes ?

To solve this problems, we need Containers.

Containers

Containers are a standard way to package an application and all its dependencies so that it can be moved between environments and run without change. They work by hiding the differences between applications inside the container so that everything outside the container can be standardized.

For example, Docker created standard way to create images for Linux Containers.

Why containers ?

  • We can run them anywhere.
  • They are lightweight .
  • Isolate your application from others.

Different Container Standards

There are many different container standards available today. Some of them are as follows.

Docker - The most common standard, made Linux containers usable by the masses.

Rocket (rkt) - An emerging container standard from CoreOS, the company that developed etcd.

Garden - The format Cloud Foundry builds using buildpacks.

Among them, Docker was one of the most popular mainstream container software tools.

Open Container Initiative (OCI)

A Linux Foundation project developing a governed container standard. Docker and Rocket are OCI-compliant. But, Garden is not.

Benefits

  • Lightweight
  • Scalable
  • Efficient
  • Portable
  • Supports agile development

To know more about Containerization, we have couple of guides. Feel free to check them out.

Docker

Docker is one of the most popular Containerization platforms which allows you to develop, deploy, and run application inside containers.

  • It is an open source project.
  • Can run it anywhere.

An installation of Docker includes an engine. This comes with a daemon, REST APIs, and CLI. Users can use CLI to interact with the docker using commands. These commands are sent to the daemon which listens for the Docker Rest APIs which in turn manages images and containers. The engine runs a container by retrieving its image from the local system or registry. A running container starts one or more processes in the Linux kernel.

Docker Image

A read-only snapshot of a container that is stored in Docker Hub or in private repository. You use an image as a template for building containers.

These images are build from the Dockerfile.

Dockerfile

  • It is a text document that contains all the instructions that are necessary to build a docker image.
  • It is written in an easy-to-understand syntax.
  • It specifies the operating system.
  • It also includes things like environmental variables, ports, file locations etc.

Docker Container

The standard unit where the application service is located or transported. It packages up all code and its dependencies so that the application runs quickly and reliably from one computing environment to another.

Docker Engine

Docker Engine is a program that creates, ships, and runs application containers. The engine runs on any physical or virtual machine or server locally, in private or public cloud. The client communicates with the engine to run commands.

Docker Registry

The registry stores, distributes, and shares container images. It is available in software as a service (SaaS) or in an enterprise to deploy anywhere you that you choose.

Docker Hub is a popular registry. It is a registry which allows you to download docker images which are built by different communities. You can also store your own images there. You can check out various images available on docker hub here.

Docker Commands

Below are some commands we use often on Docker.

# Know docker version
docker -version

# Run a container
docker run <image>

# List containers running
docker ps

# Stop a container
docker stop <container-name|container-id>

# Remove a container
docker rm <container-name|container-id>

# Login into registry
docker login

# Build an image
docker build <image_name>:<tag> .

# Pull the image
docker pull <image_name>:<tag>

# Push an image
docker push <image_name>:<tag>

# List images
docker images

If you are interested, check this course out on Containers and Docker.

Activities

Once you have completed these tasks, you should have a base understanding of containers and how to use Docker.

References