Home Docker Note - [1 to ?]
Post
Cancel

Docker Note - [1 to ?]

Docker note

I. Introduction

Docker is a container management service. The keywords of Docker are develop, ship and run anywhere. The whole idea of Docker is for developers to easily develop applications, ship them into containers which can then be deployed anywhere.

Features of Docker

  • Docker has the ability to reduce the size of development by providing a smaller footprint of the operating system via containers.

  • With containers, it becomes easier for teams across different units, such as development, QA and Operations to work seamlessly across applications.

  • You can deploy Docker containers anywhere, on any physical and virtual machines and even on the cloud.

  • Since Docker containers are pretty lightweight, they are very easily scalable.

Components of Docker

  • Docker for Mac − It allows one to run Docker containers on the Mac OS.

  • Docker for Linux − It allows one to run Docker containers on the Linux OS.

  • Docker for Windows − It allows one to run Docker containers on the Windows OS.

  • Docker Engine − It is used for building Docker images and creating Docker containers.

  • Docker Hub − This is the registry which is used to host various Docker images.

  • Docker Compose − This is used to define applications using multiple Docker containers.

Simple installation

  • Preparation
1
2
3
4
5
6
7
8
9
10
11
12
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  • Install
1
2
3
4
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Docker common

  • Docker Hub : Docker Hub is a registry service on the cloud that allows you to download Docker images that are built by other communities. You can also upload your own Docker built images to Docker hub.

  • Docker Images : An image is a combination of a file system and parameters.

  • Docker container : Containers are instances of Docker images that can be run using the Docker run command.

  • Docker command cheatsheet

II. Docker note

Container Lifecycle

image

  • Initially, the Docker container will be in the created state.

  • Then the Docker container goes into the running state when the Docker run command is used.

  • The Docker kill command is used to kill an existing Docker container.

  • The Docker pause command is used to pause an existing Docker container.

  • The Docker stop command is used to pause an existing Docker container.

  • The Docker run command is used to put a container back from a stopped state to a running state.

Architecture

The following image shows the standard and traditional architecture of virtualization.

image

1
2
3
4
5
6
7
8
9
The server is the physical server that is used to host multiple virtual machines.

The Host OS is the base machine such as Linux or Windows.

The Hypervisor is either VMWare or Windows Hyper V that is used to host virtual machines.

You would then install multiple operating systems as virtual machines on top of the existing hypervisor as Guest OS.

You would then host your applications on top of each Guest OS.

The following image shows the new generation of virtualization that is enabled via Dockers. Let’s have a look at the various layers.

image

1
2
3
4
5
6
7
The server is the physical server that is used to host multiple virtual machines. So this layer remains the same.

The Host OS is the base machine such as Linux or Windows. So this layer remains the same.

Now comes the new generation which is the Docker engine. This is used to run the operating system which earlier used to be virtual machines as Docker containers.

All of the Apps now run as Docker containers.

Docker file

  • Example Dockerfile
1
2
3
4
5
6
7
# This is a sample Image 
FROM ubuntu 
MAINTAINER demousr@gmail.com 

RUN apt-get update 
RUN apt-get install –y nginx 
CMD ["echo","Image created"] 
  • Build
1
docker build  -t ImageName:TagName dir
  • Docker pull/push/tag

Managing Ports

  • docker inspect

This method allows one to return low-level information on the container or image.

  • sudo docker run -p 8080:8080 -p 50000:50000 </b>
This post is licensed under CC BY 4.0 by the author.