DEV Community

Cover image for Smooth Sailing with Docker: A Beginner's Guide to Containerization
Ivy Jeptoo
Ivy Jeptoo

Posted on • Edited on

Smooth Sailing with Docker: A Beginner's Guide to Containerization

Welcome to Docker world where containers bring magic to the world of software development and deployment!

Why did the Docker container never ask for help?
Because it couldn't find a container support group – it was too self-contained!

Now that we've shared a giggle or a laugh let's embark on Docker exploration. In this article you'll learn docker fundamentals and it's installation...let's dive in!

TABLES OF CONTENTS

Introduction
Docker Features
Docker Architecture
Installing Docker Desktop
Conclusion

Introduction

Docker is a container management server that is used in development, packaging and deployment of applications automatically.

  • Container - is an instance of an image that allows developers package the application with all parts needed such as libraries and other dependencies.

  • Image - is a file that has multiple layers used to execute code in a docker container. They are a set of instructions used to create docker containers

How Docker works

Docker uses containerization where applications are packaged into containers that has everything they need to run(code, libraries, dependencies). Docker uses OS-level virtualization to create the containers and ensuring that each container operates as an isolated and self-contained unit.

Docker Engine - is a client-server based application that hosts containers.
It has three main components:

  • Server(Docker deamon): Creates, and manages docker images, containers, network and volumes on docker.

  • REST API(Docker Client): Allows users to interact with server, issuing commands to build, run, and manage containers.

  • Client: is a docker command-line interface(CLI), that allows interaction with docker using docker commands.

Docker Features

Scalability
Docker containers are lightweight hence easily scalable. Its portability makes it simple to manage workloads, scaling up or down apps and services as demands in real-time.

Swarm
It is a clustering and scheduling tool for docker containers. Swarm uses docker API as its front-end hence various tool to control it. It also helps us control cluster of docker hosts as a single virtual host. It's a self-organizing group of engines used to enable pluggable backends.

Security
Docker saves secret into the swarm itself. Docker container provide a high level of isolation between different application preventing them fro interacting with or affecting each other hence a more secure and stable platform for running multiple apps on a single host.

Routing Mesh
It enables connection even if there is no task running on the node. It routes the incoming requests for published ports on available nodes to an active container.

Docker Architecture

In a nutshell, the client talks with the docker deamon which helps in building, running and distributing docker containers. The client runs with the deamon on the same system or connected remotely. With the help of REST API over a network the client and deamon interacts.

docker
DOCKER CLIENT
Docker client uses commands and REST API to communicate with the server(Docker Deamon).
When a client runs any docker client terminal, the client terminal sends the docker commands to the docker deamon which receives the commands in form of command and REST API's request
Docker Client can communicate with more than one docker deamon and it uses CLI to run the docker build, docker pull, docker run.

DOCKER HOST
Provides an environment to execute and run applications. It contains docker deamon, containers, images, network and storage.

DOCKER REGISTRY
Manages and stores docker images.
It is of two types:

  • Public Registry - Also called Docker Hub is used by everyone.
  • Private Registry - uses to share images within the enterprise.

DOCKER OBJECTS

OBJ

  • Docker Image - are the read-only binary templates used to create Docker Containers. Images enables collaboration between developers.

  • Docker Containers - is used to hold the entire package that is needed to run the application. containers need less resources which is a plus. Containers is a copy of a template while the image is a template.

  • Docker Networking - provides isolation for docker containers, it links docker container to many networks.
    Types of Docker Network

  • Bridge - default network driver for the container, used when when multiple docker communicates with the same docker host.

  • Host - used when we don't need network isolation between container and host.

  • None - disables all the networking.

  • Overlay - enables containers to run on different docker host. Offers Swarm services to communicate with each other.

  • Macvlan - Used when we want to assign MAC (Media Access Control)addresses to the container.

Docker Storage
It is used to store data in containers. Docker has the following storage options;-
Data Volume - provides the ability to create persistence storage, it allows us to name volumes, list volumes and containers associated with the volume.
Directory Mounts - it mounts host's directory with a container, it is the best option.
Storage Plugins - it provides ability to connect to external storage platforms.

Installing Docker Desktop

We can install docker on any operating system but docker runs natively on Linux distributions. We will install docker engine for linux Ubuntu.

Prerequisites
To Install docker Desktop ensure that:

  • Have a 64-bit version of either Ubuntu Jammy Jellyfish 22.04 (LTS) or Ubuntu Impish Indri 21.10. Docker Desktop is supported on x86_64 (or amd64) architecture.

  • Meet the system requirements

Steps

  1. Set up Docker's package repository
  2. Download latest DEB package
  3. Install the package with apt:
`sudo apt-get update`
`sudo apt-get install ./docker-desktop-<version>-<arch>.deb`
Enter fullscreen mode Exit fullscreen mode

Launch Docker Desktop using the terminal:

`systemctl --user start docker-desktop`
Enter fullscreen mode Exit fullscreen mode

or search Docker Desktop on Applications menu and open it.
Check docker binary versions by running:

`docker compose version` 
`docker --version`
`docker version`
Enter fullscreen mode Exit fullscreen mode

To login to docker

`systemctl --user enable docker-desktop`
Enter fullscreen mode Exit fullscreen mode

To stop Docker Desktop

systemctl --user stop docker-desktop
Enter fullscreen mode Exit fullscreen mode
  • If you are using Windows you can install it from here or if you are using Mac you can find docker installation here

Conclusion

Remember, Docker is a powerful tool with numerous advanced features and use cases. Continue learning by referring to the official Docker documentation and community resources. Embrace the world of containerization and elevate your software development and deployment workflows with Docker. Happy containerizing!

Top comments (1)

Collapse
 
camron_david_98d94f936dc7 profile image
Camron David

Helps me