• CentOS7安装Docker遇到的问题笔记


    笔记/朱季谦

    以下是笔者本人学习搭建docker过程当中记录的一些实践笔记,过程当中也遇到了一些坑,但都解决了,就此记录,留作以后再次搭建时可以直接参考。

    一、首先,先检查CentOS版本,保证在CentOS7版本以上,系统内核在3.10以上——

    1. [root@192 opt]# uname -r
    2. 3.10.0-693.el7.x86_64

    二、卸载旧的docker版本

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

    三、安装需要的依赖包

    sudo yum install -y yum-utils
    

    四、设置国内镜像的仓库

    1. sudo yum-config-manager \
    2. --add-repo \
    3. http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

    五、更新yum软件包索引

    yum makecache fast 
    

    六、安装docker相关 docker-ce 社区 docker ee企业版

    sudo yum install docker-ce docker-ce-cli containerd.io
    

    七、启动docker

    systemctl start docker
    

    这时,出现了一个很奇怪的异常:

    Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

    不慌,我们先检查一下daemon.json文件格式:

    vim /etc/docker/daemon.json
    

    发现这个daemon.json文件里是这样的,也不知道为啥直接更新下载后,它会缺少了部分字符......

    image

    需要修改成这样,就可以了

    1. {"registry-mirrors": ["http://9600955f.m.daocloud.io"],
    2. "insecure-registries": []
    3. }

    接下来,可以正常启动docker了——

    1. [root@192 opt]# systemctl daemon-reload
    2. [root@192 opt]# systemctl start docker

    如果不报错,输入systemctl status docker.service,若显示以下信息则证明启动安装并启动成功:

    image

    安装成功后,使用docker version,一般会出现以下信息:

    1. [root@192 opt]# docker version
    2. Client: Docker Engine - Community
    3. Version: 20.10.8
    4. API version: 1.41
    5. Go version: go1.16.6
    6. Git commit: 3967b7d
    7. Built: Fri Jul 30 19:55:49 2021
    8. OS/Arch: linux/amd64
    9. Context: default
    10. Experimental: true
    11. Server: Docker Engine - Community
    12. Engine:
    13. Version: 20.10.8
    14. API version: 1.41 (minimum version 1.12)
    15. Go version: go1.16.6
    16. Git commit: 75249d8
    17. Built: Fri Jul 30 19:54:13 2021
    18. OS/Arch: linux/amd64
    19. Experimental: false
    20. containerd:
    21. Version: 1.4.9
    22. GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
    23. runc:
    24. Version: 1.0.1
    25. GitCommit: v1.0.1-0-g4144b63
    26. docker-init:
    27. Version: 0.19.0
    28. GitCommit: de40ad0

    尝试下拉取hello-world时,发现出现一个超时问题:

    1. [root@192 opt]# docker run hello-world
    2. Unable to find image 'hello-world:latest' locally
    3. docker: Error response from daemon: Get "https://registry-1.docker.io/v2/library/hello-world/manifests/sha256:393b81f0ea5a98a7335d7ad44be96fe76ca8eb2eaa76950eb8c989ebf2b78ec0": net/http: TLS handshake timeout.
    4. See 'docker run --help'.

    这时,需要把daemon.json文件里的信息改一下,改成国内阿里云镜像配置,可以提高拉取速度,避免超时问题,如下:

    1. {"registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com"],
    2. "insecure-registries": []
    3. }

    接着,重启systemctl restart docker,即可。

    [root@192 opt]# sudo systemctl restart docker
    

    再试着执行docker run hello-world,这次就正常了:

    1. [root@192 opt]# docker run hello-world
    2. Unable to find image 'hello-world:latest' locally
    3. latest: Pulling from library/hello-world
    4. 2db29710123e: Pull complete
    5. Digest: sha256:393b81f0ea5a98a7335d7ad44be96fe76ca8eb2eaa76950eb8c989ebf2b78ec0
    6. Status: Downloaded newer image for hello-world:latest
    7. Hello from Docker!
    8. This message shows that your installation appears to be working correctly.

    查看一下是否已经成功下载hello-world镜像,可以看到,hello-world镜像已经被拉到了docker当中:

    1. root@192 opt]# docker images
    2. REPOSITORY TAG IMAGE ID CREATED SIZE
    3. hello-world latest feb5d9fea6a5 40 hours ago 13.3kB
    4. nginx latest f35646e83998 11 months ago 133MB
    5. ubuntu latest 549b9b86cb8d 21 months ago 64.2MB
  • 相关阅读:
    苹果或推出多屏幕iPhone;​爱彼迎CEO:办公室时代已过去;Apache Flink 1.15 发布|极客头条
    使用C#跨PC 远程调用程序并显示UI界面
    【SpringBoot高级篇】SpringBoot集成Mybatis实现多数据源配置+跨数据源事务
    Odoo免费开源ERP订单锁货的应用实施技巧分享
    arcgis栅格按某列属性导出
    中秋快乐! Happy Mid-autumn Festival!
    使用IDEA连接mysql
    引用类型详解
    C++ 基础(十二)函数-题目练习
    excel常用函数
  • 原文地址:https://blog.csdn.net/weixin_40706420/article/details/134522884