1 Docker


Here’ s flag: i will take down all the notes concerning Docker in English while going through training courses from Udemy site . Not as difficult as some people may think .
I really was good at English a few years ago.Perhaps it 's a great chance to pick it up and get it refreshed .

1、Why Docker?

Simply , to make it easy to install softwares not worrying about setup and dependices.
Say,you can’t install a Redis server on a Mac by ‘wget’ it from remoting,since ‘wget’ is a
Linux cmd.
Wow,you have to identify cmd adapted to Mac before you do install a Redis.That’s a trouble .

2、What’s Docker?

Look at the first pic.
When people say ‘i use Docker’ ,what on earth are they talk about .
Docker means an entire ecosystem ,and it’s not simply a specific software.
在这里插入图片描述

First of all ,here are two core concepts,namely , images and containers.

  • Images : a single file
  • Containers: an instance of image. Just think of it as a program with its own isolated set of hardware resources, memory, networking,hard drive,etc.
    A container’s sole purpose is to run one very specific program so the Docker server then essentially takes that single file,loads it up into memory ,creates a container out of it,and then runs a single program inside.
    在这里插入图片描述

3、Docker on your OS

It’s a big issue that you tell the difference between Docker client(also named as Docker Cli) and Docker Server( also Docker Daemon).

In the Linux world ,Daemon means the specific program that runs the service.NOT necessary to isolate them from each other ,just treat them as the same thing.
在这里插入图片描述
We now comes to the right point.How do we install an Docker.
Click https://www.docker.com/get-started for detailed steps,and i am not going to describe it here.
But you’d better know that Docker Desktop for Windows runs OK both on linux and Windows.Just checkout it out on this website.

4、Hello-world

After you give a cmd of ‘Docker run hello-world’ ,Docker do four steps:

  1. the Docker Cli receives the cmd ,and issues it to the Docker Server
  2. Docker Server looks for the ‘hello-world’ image in the local cache. Image is a file,as i described just now.
  3. Since it’s the first time we run the cmd, the image cache ,certainly ,is empty.Then Docker server contacts the Docker Hub for a ‘hello-worl’ docker image (file).
  4. Of course,the Docker Hub has got the docker image ,and it passes the file to Dokcer Server .Server saves the file into the cache,and downloads the software as configurated in the file.
    在这里插入图片描述

5、What the Container is

We answer this question in this scene:
Provided that you run chrome that needs Python V2 ,and you run NodeJS that needs Python3.However ,you only have Python2 on your hard drive.Now ,your NodeJS may not properly function .
What would you do to tackle this embarrasing problem?
Docker comes up with a good idea based on a crux named ‘Name Spacing’.This technique segments hard drive into pieces.If Chrome calls,the kernel directs that call over to the according little segment ,and it works for NodeJS as well.So ‘Name Spacing’, kind of some mechanism to isloate resources.
在这里插入图片描述
**Addtionally, NameSpacing can also be applied to Software,not merely Hardware.**Technically, the flow above only describes how it functions on hard disk.Now ,the charts below illustrates the software side.

  • In these charts,NameSpacing isolate resources per prorcess,or group of processes.
    For example,we can namespace a process to restrict the area of a hard drive that is available or the network devices that are available, etc.(即:利用“name spacing” 限定了进程所能利用的 软、硬件资源。
  • A very close concept is Control Groups(Cgroups),cgroups limit the amount of resources that a particular process can use.

在这里插入图片描述
Namespacing and cgroups together make it possible to isolate resources and take processes under controll.

Now come back to the point.What is the container?
The given area within the dashed line box tells us what it is .Container is not a physical construct .Instead ,a container is really a set of processes that have a grouping of resources specifically assinged to it.To make it clear , i think you should look and see another pic down there .
在这里插入图片描述

在这里插入图片描述

So ,now ,what is the relationship between a container and an image.Fine,just look at this diagram.
An image is technically a FS snapshot ,with a startup cmd.
在这里插入图片描述

6、How Docker runs on Mac or Windows

Namespcing ,and cgroups are only specific to Linux OS ,but Docker runs well on a Mac or Windows.How does it make it ?
Well, when we install a Docker on a PC or Mac ,we also install a Linux Virtual Machine,which behaves as the host of running processes.
You can confirm it as you input ‘docker version’ on your OS ,and look at the ‘Server’ section.Basically,it reads ’ Linux’! That’ pretty much it.
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值