Docker Dive Part 1 — Basics

Nuwan Tissera
2 min readJul 6, 2019

--

Why Dockers?

Dockers let the software install and run easily without thinking about setup and scaling.

What is Docker?

Eco-system or Platform for creating and running containers.

So, What is a Container?

A container is an instance of an image. We can create and run many containers out of one image. Each Container has its own isolated set of resources such as memory, networking, hard drive space etc.

Benefits of Container

Namespacing: Isolate resource per processes or groups.

Control groups: Limit amount of resources per processes.

What is an Image?

Simply, Single file with all the Configurations required to run a program.

Docker Ecosystem

We call Docker to all of these following. So don't get mess up. We need to clarify all.

Docker Ecosystem

Docker Commands

  • DOCKER | RUN | <IMAGE NAME> — Download the docker image, Copy it into a container, run the container.

DOCKER RUN = DOCKER CREATE <imageNAME> + DOCKER START -a <containerID>

docker run hello-world

When we type the above command in the terminal, Its 1st identified by Docker client, Then Docker client asks the Docker Server to download the specified image (e.g: hello-world) from Docker Hub to the machine.

Docker Hub is a public repository of Docker images available online.

  • DOCKER | RUN | <IMAGE NAME> | <COMMAND> — download, run plus run the command inside the container.
docker run busybox echo hi

This is will download Doker image “busybox” to local machine and execute the echo hi command against the container. Btw command should be to execute inside the container to give results. Else it will give errors as following.

docker: Error response from daemon: OCI runtime create failed:
  • DOCKER | PS — Show running containers.
docker run busybox ping google.com

run above command and type docker ps.

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
4cbffad75d91 busybox "ping google.com" 45 seconds ago Up 44 seconds awesome_stonebraker

If we run `docker run hello-world echo hi`, container `echo hi` and stop its work. So container moves to exit state.

--

--

Nuwan Tissera
Nuwan Tissera

Written by Nuwan Tissera

Software Engineer WSO2 | Msc in CSE UoM | Blogger

No responses yet