DEV Community

Cover image for Brief overview of Docker
Derick Ify Iloabachie
Derick Ify Iloabachie

Posted on • Edited on

Brief overview of Docker

What is Docker?

Docker is an open-source containerization platform that enables developers to easily create, deploy, and run applications in containers.

A container is a lightweight, standalone executable package that includes everything needed to run the application, such as code, runtime, system tools, libraries, and settings.

Under the hood

Docker uses namespaces to assign a partition of a machine to a container

Namespaces are a feature of the Linux kernel that partitions kernel resources such that one set of processes sees one set of resources and another set of processes sees a different set of resources. Docker uses namespaces to provide this isolation to the containers from the host

Running process  System Call   Kernel  [Resources eg.. CPU, RAM, HDD, etc]
Enter fullscreen mode Exit fullscreen mode

Kernel is a computer program at the core of a computer’s OS and generally has complete control over everything. It tells the computer how to run commands and how to talk to the hardware from the software. It basically facilitates the interactions between hardware and software components

Volumes - Data storage and usage in Docker

We often need to store configuration files, application data, and other files that need to persist beyond the lifetime of a container. For this, docker provides a persistent data storage mechanism which can be mounted into a container at runtime.

When a volume is created in Docker, it is stored outside of the container's file system, usually on the host machine. This means that even if a container is deleted, the data stored in the volume will not be deleted.

Types of Volumes in Docker

Named volumes:

  • They are given a specific name
  • Cannot be created in the Dockerfile (only command line)
  • Survives container shutdown, restart and removal via CLI
  • Can be reused and shared across containers

Anonymous Volumes:

  • As the name implies, they are created witthout a specific name
  • Created specifically for one container
  • Survives normal container shutdown and restart (but not removal)
  • Cannot be shared across containers
  • Cannot be reused even by the same container

Bind mounts

  • Allows mounting a directory on the host machine into a container
  • Typical usage is for providing live data without having to rebuild the container in development
  • Location is on host file system and not tied to any specific container
  • Survives container shutdown and restart since the location on the host computer is known
  • Can be reused and shared across containers

Communication in Docker containers

Docker containers can communicate to APIs outside of the container and outside of the host normally.

Communication between Docker containers can be achieved using different networking modes provided by Docker. The networking mode determines how containers can communicate with each other and with the host machine.

By default, when a container is created, Docker creates a network namespace for the container, which isolates the container from the host machine and other containers. Containers can communicate with each other on the same network by using the container name or IP address.

Conclusion

Docker is a fascinating technology as it provides a consistent environment across different operating systems and infrastructure, making it easier to develop and deploy applications in different environments.
To learn more about docker, please see the docs

Top comments (0)