• Docker 笔记(一)--安装


    Docker 笔记–安装

    记录Docker 安装操作记录,便于查询。

    参考

    1. 链接: Docker 入门到实战教程(二)安装Docke
    2. 链接: docker入门(利用docker部署web应用)
    3. 链接: 阿里云容器镜像服务/镜像加速器/操作文档
    4. 链接: 网易镜像中心
    5. 链接: 阿里云镜像站

    环境

    Centos 7.9

    安装

    1.检查操作系统环境和版本

    Docker 要求 CentOS 系统的内核版本高于 3.10,系统为64位

    [root@centos7-18 ~]# cat /etc/redhat-release 
    CentOS Linux release 7.9.2009 (Core)
    Red Hat Enterprise Linux Server release 4.5 (Tikanga)
    [root@centos7-18 ~]# 
    
    • 1
    • 2
    • 3
    • 4
    [root@centos7-18 ~]# uname -r
    3.10.0-1160.6.1.el7.x86_64
    [root@centos7-18 ~]# 
    
    • 1
    • 2
    • 3

    2.如果安装过,需要先卸载

    yum remove docker \
               docker-client \
               docker-client-latest \
               docker-common \
               docker-latest \
               docker-latest-logrotate \
               docker-logrotate \
               docker-engine
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    3.安装Docker

    3.1 安装依赖

    [root@centos7-18 ~]# yum install -y yum-utils  device-mapper-persistent-data  lvm2
    
    • 1

    3.2 添加Docker源
    使用阿里云的Docker源

    [root@centos7-18 yum.repos.d]#yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
     
     已加载插件:fastestmirror, langpacks
    adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
    repo saved to /etc/yum.repos.d/docker-ce.repo
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    [root@centos7-18 yum.repos.d]#  ll  /etc/yum.repos.d/
    总用量 60
    -rw-r--r--. 1 root root 2523 616 2018 CentOS-Base.repo
    -rw-r--r--. 1 root root 1664 1130 2016 CentOS-Base.repo.bak
    -rw-r--r--. 1 root root 1309 1023 2020 CentOS-CR.repo
    -rw-r--r--. 1 root root  649 1023 2020 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root  314 1023 2020 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root  630 1023 2020 CentOS-Media.repo
    -rw-r--r--. 1 root root 1331 1023 2020 CentOS-Sources.repo
    -rw-r--r--. 1 root root 8515 1023 2020 CentOS-Vault.repo
    -rw-r--r--. 1 root root  616 1023 2020 CentOS-x86_64-kernel.repo
    // Docker源
    -rw-r--r--  1 root root 2081 1115 2023 docker-ce.repo
    -rw-r--r--. 1 root root 1050 111 2020 epel.repo
    -rw-r--r--. 1 root root 1149 111 2020 epel-testing.repo
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    3.3 安装最新版

    [root@centos7-18 yum.repos.d]# sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
    • 1

    安装说明: 摘自《功能解释:containerd.io、docker-ce、docker-ce-cli、docker-buildx-plugin、docker-compose-plugin、docker.io》

    • docker containerd.io
      Docker容器运行时的核心组件之一,它负责管理和运行容器。它提供了容器的生命周期管理、镜像管理、网络管理等功能。

    • docker-ce
      是Docker Community Edition的缩写,是Docker的社区版本。它是一个开源的容器化平台,提供了构建、发布和运行容器的工具和服务。广义来说,docker-ce包含了dockerd(Docker守护进程)、docker命令行工具、docker-compose等组件;狭义上来讲,docker-ce 是与 docker containerd.io、docker-ce-cli 并列的服务组件。

    • docker-ce-cli
      是Docker Community Edition的命令行工具(command line)。它提供了与Docker守护进程进行交互的命令行接口,可以用于管理和操作Docker容器、镜像、网络等。

    • docker-buildx-plugin
      是Docker的一个插件,用于构建多平台的容器镜像。它可以在一个构建过程中同时构建多个不同平台的镜像,例如x86、ARM等。这样可以方便地为不同平台的设备提供适配的容器镜像。

    • docker-compose-plugin
      是Docker的一个插件,用于管理和编排多个容器的运行。它可以通过一个单独的配置文件定义多个容器之间的关系和依赖,然后通过简单的命令就可以启动、停止、删除这些容器。

    3.4 查看版本

    [root@centos7-18 yum.repos.d]# docker version
    Client: Docker Engine - Community
     Version:           24.0.7
     API version:       1.43
     Go version:        go1.20.10
     Git commit:        afdd53b
     Built:             Thu Oct 26 09:11:35 2023
     OS/Arch:           linux/amd64
     Context:           default
    Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    3.5 启动Docker

    [root@centos7-18 yum.repos.d]# systemctl start docker
    // 添加开机自启动
    //[root@centos7-18 yum.repos.d]# systemctl enable docker
    
    • 1
    • 2
    • 3
    [root@centos7-18 yum.repos.d]# ps -ef | grep docker
    root     12338     1  0 13:43 ?        00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    root     12792  9696  0 13:49 pts/0    00:00:00 grep --color=auto docker
    [root@centos7-18 yum.repos.d]# 
    
    • 1
    • 2
    • 3
    • 4

    3.6 配置国内镜像源

    {
      "registry-mirrors": [
            // 阿里云的配置详见“容器镜像服务”-“镜像加速器”-“对应的操作系统”
            "https://xxxxxxx.mirror.aliyuncs.com",
            "http://hub-mirror.c.163.com",
            "https://docker.mirrors.ustc.edu.cn",
            "https://registry.docker-cn.com"
      ]
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    [root@centos7-18 docker]# systemctl daemon-reload
    [root@centos7-18 docker]# systemctl restart docker
    
    • 1
    • 2
    [root@centos7-18 docker]# docker info
    Client: Docker Engine - Community
     Version:    24.0.7
     Context:    default
     Debug Mode: false
     Plugins:
      buildx: Docker Buildx (Docker Inc.)
        Version:  v0.11.2
        Path:     /usr/libexec/docker/cli-plugins/docker-buildx
      compose: Docker Compose (Docker Inc.)
        Version:  v2.21.0
        Path:     /usr/libexec/docker/cli-plugins/docker-compose
    
    Server:
     Containers: 0
      Running: 0
      Paused: 0
      Stopped: 0
     Images: 0
     Server Version: 24.0.7
     Storage Driver: overlay2
      Backing Filesystem: xfs
      Supports d_type: true
      Using metacopy: false
      Native Overlay Diff: true
      userxattr: false
     Logging Driver: json-file
     Cgroup Driver: cgroupfs
     Cgroup Version: 1
     Plugins:
      Volume: local
      Network: bridge host ipvlan macvlan null overlay
      Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
     Swarm: inactive
     Runtimes: io.containerd.runc.v2 runc
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
     runc version: v1.1.9-0-gccaecfc
     init version: de40ad0
     Security Options:
      seccomp
       Profile: builtin
     Kernel Version: 3.10.0-1160.6.1.el7.x86_64
     Operating System: CentOS Linux 7 (Core)
     OSType: linux
     Architecture: x86_64
     CPUs: 2
     Total Memory: 1.791GiB
     Name: centos7-18.localdomain
     ID: ff9448d2-60cd-4dfb-8d41-26afa972b45b
     Docker Root Dir: /var/lib/docker
     Debug Mode: false
     Experimental: false
     Insecure Registries:
      127.0.0.0/8
     Registry Mirrors:
      https://xxxxxxxx.mirror.aliyuncs.com/
      http://hub-mirror.c.163.com/
      https://docker.mirrors.ustc.edu.cn/
      https://registry.docker-cn.com/
     Live Restore Enabled: false
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62

    镜像源

    网易:http://hub-mirror.c.163.com
    中科大镜像地址:http://mirrors.ustc.edu.cn/
    中科大github地址:https://github.com/ustclug/mirrorrequest
    Azure中国镜像地址:http://mirror.azure.cn/
    Azure中国github地址:https://github.com/Azure/container-service-for-azure-china
    DockerHub镜像仓库: https://hub.docker.com/ 
    阿里云镜像仓库: https://cr.console.aliyun.com 
    google镜像仓库: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以翻墙的话是可以连上去的 )
    coreos镜像仓库: https://quay.io/repository/ 
    RedHat镜像仓库: https://access.redhat.com/containers
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  • 相关阅读:
    神经网络-Unet网络
    小学生python游戏开发pygame5--title地图调用
    壳聚糖/纳米金水凝胶/纳米木质素/掺杂二硫化钼/微米级Ag2O2掺杂壳聚糖水凝胶的制备研究
    【Azure Event Hub】Event Hub的Process Data页面无法通过JSON格式预览数据
    OpenCV DNN模块常用操作
    青少年软件编程(Python语言)等级考试试卷目录一览
    上海无居住证120积分随迁子女如何求学(中考)
    力扣记录:剑指offer(6)——JZ53-58
    CSS中alpha没有效果
    医学影像工作站PACS系统源码,医院PACS系统源码
  • 原文地址:https://blog.csdn.net/shijin741231/article/details/134416186