尚硅谷Docker实战教程-笔记02【安装docker、镜像加速器配置】

  1. 尚硅谷Docker实战教程-笔记01【理念简介、官网介绍、平台入门图解、平台架构图解】
  2. 尚硅谷Docker实战教程-笔记02【安装docker、镜像加速器配置】
  3. 尚硅谷Docker实战教程-笔记03【】
  4. 尚硅谷Docker实战教程-笔记04【】
  5. 尚硅谷Docker实战教程-笔记05【】

目录

1.基础篇

2.Docker安装

P011【11_centos7上安装docker】17:08

P012【12_镜像加速器配置】08:08

P013【13_helloworld分析介绍3要素配合】03:48

P014【14_为什么Docker会比VM虚拟机快】05:12


1.基础篇

2.Docker安装

P011【11_centos7上安装docker】17:08

Install Docker Engine on CentOS | Docker Documentation

[root@node001 ~]# systemctl start docker
[root@node001 ~]# ps -ef|grep docker
root       3649      1  5 14:57 ?        00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root       3793   3143  0 14:58 pts/0    00:00:00 grep --color=auto docker
[root@node001 ~]# docker version
Client: Docker Engine - Community
 Version:           24.0.1
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        6802122
 Built:             Fri May 19 18:06:42 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.1
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       463850e
  Built:            Fri May 19 18:05:43 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@node001 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete 
Digest: sha256:fc6cf906cbfa013e80938cdf0bb199fbdbb86d6e3e013783e5a766f50f5dbce0
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[root@node001 ~]# history 
  186  yum -y install gcc
  187  yum -y install gcc-c++
  188  yum install -y yum-utils
  189  yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  190  yum makecache fast
  191  yum install docker-ce docker-ce-cli containerd.io
  192  systemctl start docker
  193  ps -ef|grep docker
  194  docker version
  195  docker run hello-world
  196  history 
[root@node001 ~]# 

P012【12_镜像加速器配置】08:08

阿里云-计算,为了无法计算的价值

[root@node001 ~]# pwd
/root
[root@node001 ~]# cd /etc/docker/
[root@node001 docker]# tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://xukpfkbt.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://xukpfkbt.mirror.aliyuncs.com"]
}
[root@node001 docker]# systemctl daemon-reload
[root@node001 docker]# systemctl restart docker
[root@node001 docker]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[root@node001 docker]# 

P013【13_helloworld分析介绍3要素配合】03:48

P014【14_为什么Docker会比VM虚拟机快】05:12

为什么Docker会比VM虚拟机快?

(1)docker有着比虚拟机更少的抽象层

   由于docker不需要Hypervisor(虚拟机)实现硬件资源虚拟化,运行在docker容器上的程序直接使用的都是实际物理机的硬件资源。因此在CPU、内存利用率上docker将会在效率上有明显优势。

(2)docker利用的是宿主机的内核,而不需要加载操作系统OS内核

   当新建一个容器时,docker不需要和虚拟机一样重新加载一个操作系统内核。进而避免引寻、加载操作系统内核返回等比较费时费资源的过程,当新建一个虚拟机时,虚拟机软件需要加载OS,返回新建过程是分钟级别的。而docker由于直接利用宿主机的操作系统,则省略了返回过程,因此新建一个docker容器只需要几秒钟。

猜你喜欢

转载自blog.csdn.net/weixin_44949135/article/details/130885993