Smooth Sailing with Docker: A Beginner's Guide to Containerization
Tags: docker, beginners, cloudcomputing
Published: 2023-05-14 09:31:52

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](#introduction)
 [Docker Features](#docker-features)
 [Docker Architecture](#docker-architecture)
 [Installing Docker Desktop](#installing-docker-desktop)
 [Conclusion](#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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywtl0f2lu6qjobquovjs.jpeg)
**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w9y6jpd2cllpm0a56fgi.png)

- **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](https://docs.docker.com/desktop/install/linux-install/#system-requirements)

**Steps**
1. Set up [Docker's package repository](url)
2. Download latest [DEB package](https://desktop.docker.com/linux/main/amd64/docker-desktop-4.19.0-amd64.deb?utm_source=docker&utm_medium=webreferral&utm_campaign=docs-driven-download-linux-amd64)
3. Install the package with apt:

```
`sudo apt-get update`
`sudo apt-get install ./docker-desktop-<version>-<arch>.deb`
```
Launch Docker Desktop using the terminal:

```
`systemctl --user start docker-desktop`
```
 or search _Docker Desktop_ on _Applications_ menu and open it.
Check docker binary versions by running:

```
`docker compose version` 
`docker --version`
`docker version`
```
To login to docker 

```
`systemctl --user enable docker-desktop`
```
To stop Docker Desktop

```
systemctl --user stop docker-desktop
```

- If you are using Windows you can install it from [here](https://docs.docker.com/desktop/install/windows-install/#:~:text=Double%2Dclick%20Docker%20Desktop%20Installer,bottom%20of%20your%20web%20browser.)  or if you are using Mac you can find docker installation [here](https://docs.docker.com/desktop/install/mac-install/)

##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!