ITInnovDesign
Latest Posts:

Beginners: In-depth study for containers based technologies
Beginners: In-depth study for containers based technologies

Beginners: In-depth study for containers based technologies.

Just another post about containers and docker (examples are from windows OS)!!!

Containers like virtual machines (VM) are also a virtualization technology; however, they do not virtualize a physical server. Instead, a container is an operating system-level virtualization. What this means is that containers share the operating system kernel, provided by the host, among themselves along with the host. Multiple containers running on a host (physical or virtual) share the host operating system kernel. Containers ensure that they reuse the host kernel instead of each having a dedicated kernel to themselves.

With the concept above in mind, containers fit very well as microservice runtime engine, we can say that they are the most appropriate runtime
environment considering the requirements of scalability, reliability, and responsiveness of today’s applications.

A container has the perception that it has a completely new and untouched operating system and resources. The image bellow show where container seat on microsoft windows operating system stack.

Containers have the following advantages:

  • Containers are fast to provision. They do not need to provide the operating system and its kernel services. They are available from the host operating system.
  • Containers are lightweight and require fewer computing resources than virtual machines. The operating system resource overhead is no longer required in containers.
  • Containers are much smaller than virtual machines.
  • Containers help solve problems related to managing multiple application dependencies in an intuitive, automated, and simple manner.
  • Containers provide infrastructure to define all application dependencies in a single place.

Container runtimes are standardized under the Container Runtime Interface (CRI) so that container orchestrators such as Kubernetes can support different runtimes. There are open source and licensed container runtimes available in the market, such as Docker Engine(This was started in 2013 and is currently being supported by Docker Inc), CRI-O(sponsored by the Cloud Native Computing Foundation (CNCF) and was started in 2016 as a lightweight Kubernetes-specific runtime), and Kata Containers(This is the youngest runtime environment, which was started in 2017 and is supported by Intel).

In this post I’ll be focus on Docker Engine

Docker is an open source container runtime system based on Linux containers. Linux containers use Linux kernel features such as namespaces, control groups (cgroups), and layered filesystems:
• Namespaces: Namespaces isolate each application from the host and other
applications by creating separate environments.
• cgroups: In Linux, cgroups are used to limit applications for a specific set of
resources such as memory or processing power.
• Layered filesystems: Layered filesystems consist of reusable layers stacked on top of each other to form the base of a root filesystem. They are the primary technology that enables containers to be lightweight.

Let’s look at the image bellow to descrive Docker concepts

Docker Engine is the layer on top of the operating system where the containers run. It consists of the Docker Daemon running in the host system and the Docker Client in order to communicate with its daemon service. Docker Daemon is the service that runs on the host system and manages the containers and their interactions with external systems, on windows OS, the docker daemon is a windows service when you install docker for windows, and we can easily checked it from windows service manager.

Docker Client on the other hand, is the tool that is used for interacting with Docker Daemon and, by default, it is accessible by a Docker command in the Terminal. In a system where Docker is installed and running, like on windows operating system, just fire the command line tool and the version and API information can be checked using the following command:

This lists the version of the client and server with the corresponding API versions and further information about the runtime environment. This command is helpful if any unexpected API mismatches occur between the client and the daemon.

Docker images are read-only packages, which can include operating system libraries and application requirements, if necessary. Docker images are defined using Dockerfiles which include stepwise actions on the base image. Dockerfiles are used when Docker images are built, and each step that is specified in a Dockerfile is executed on the base image. Official and community-maintained images are designed to be stored in the
Docker registry, and Docker Hub is the official one; for instance, microsoft asp.net core runtime images can be checked in the Docker registry (docker hub), as follows :

we can see from the image above how you can pull or run the image from docker client interface.

Docker containers are running instances of Docker images that consist of an execution environment for applications. They are expected to run many instances of the same Docker image; in other words, multiple Docker containers. Two essential features are added to containers in addition to the images; first, since Docker images are read-only, Docker containers include an additional filesystem layer to enable read-and-write
capabilities. Additionally, a network interface is attached to those containers with an available IP so that containers are reachable from the host system and from outside. The flow of Docker images to the registry, and then to the containers is summarized in the image bellow:

To recap the concepts about docker technology we can say that;

The Docker daemon is the workhorse for managing containers.In windows operating system, it is a Windows service responsible for managing all activities on the host related to containers. The Docker client interacts with the Docker daemon and is responsible for capturing inputs and sending them across to the Docker daemon. The Docker daemon provides the runtime, libraries, graph drivers, and engine to create, manage, and monitor containers and images on the host server. It also has the ability to create custom images that are used for building and shipping applications to multiple environments.

To conclude this tutorial, let’s try to run a wordpress site on docker engine without writing docker file but by pulling all images from docker hub. To run a wordpress side, we need two things: a wordpress image and mysql image was demonstrated in my last post. (don’t worry, I’ll post many topics about docker and how to write docker file from scratch or by using visual studio)

  • first open a new windows command line and fire the script bellow for mysql image:

view rawrun mysql docker image hosted with ❤ by GitHub

The command bellow suppose you are in “C:/Users” folder and there is a sub folder call “data”, which is use to mount a volume (this will be clarify in another post), this volume is a share drive on the host machine where mysql will store data, containers are usually stateless and volume is a way to help us persisted container data. the command also set some environment variables which will be usefull when running the wordpress image. We mapped port 3306 for the host machine to container port 3306.

  • open another windows command line tool and run the script bellow for wordpress image:

view rawrun wordpress docker image hosted with ❤ by GitHub

we are just running a wordpress image (container), we link it to the mysql container we have just running on another command line windows, then we set some environment variables to connect wordpress site to mysql db.We also mapped the port 8080 from the host machine to 80 port inside docker container.

launch a browser and type httP://localhost:8080, just all you’ll see the wordpress admin page

you can create your site as you usually do in wordpress because you have a full wordpress solution running but inside a container. to clean containers and image, just run the command bellow:

view rawstop docker running container hosted with ❤ by GitHub

I hope this tutorial was helpful and see you next time for other topics.

regards


Author: admin
21.08.2022, 13:31
Category: Cloud Computing
Comments: 2
Views: 681
-

Share

Comments (2)
admin
admin Administrator

oui @Yvanol en fait c'est un bon topic qu'il faut comprendre et savoir en tant que dev, je vais faire une article pas à pas en français ou je vais entrer plus en profondeur

21.08.2022, 18:10

YVANOL FOTSO
YVANOL FOTSO User

l'initiative la plateforme est super .je penses que avec ce post je vais recommencer l'installation de dockers sur mon pc car j'avais essayé de l'installer a deux reprises sans succès😊

21.08.2022, 16:01


Leave A Comment
processing...