• Ubuntu20.04安装docker


    1. //删除旧版本
    2. sudo apt-get remove docker docker-engine docker.io containerd runc
    3. //更新软件包
    4. sudo apt-get update
    5. //安装需要的包
    6. sudo apt-get install apt-transport-https ca-certificates software-properties-common curl
    7. //添加官方GPG秘钥,Docker-ce 软件源
    8. curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo apt-key add -
    9. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    10. //添加中国科技大学的 Docker-ce 源,其中$(lsb_release -cs)返回Ubuntu发行版的名称
    11. curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
    12. sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
    13. $(lsb_release -cs) stable"
    14. //注意:添加错了可以用以下命令删除
    15. #查询keyid
    16. sudo apt-key list
    17. #keyid 就是90那一串
    18. sudo apt-key del <keyid>
    19. #加参数-r可以移除
    20. sudo add-apt-repository -r "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    21. //更新软件包
    22. sudo apt-get update
    23. //安装docker-ce
    24. sudo apt-get install docker-ce
    25. //测试运行,默认镜像源,运行hello-world会报错,因为网络问题
    26. docker --version
    27. docker run hello-world
    28. //查询可以安装的软件包版本
    29. apt-cache madison docker-ce
    30. //安装指定的版本
    31. sudo apt-get install docker-ce=<版本号>
    32. //查询安装的位置
    33. dpkg -L docker-ce

    docker 设置国内镜像源

    1.Docker中国区官方镜像
    https://registry.docker-cn.com

    2.网易
    http://hub-mirror.c.163.com

    3.ustc 
    https://docker.mirrors.ustc.edu.cn

    4.中国科技大学
    https://docker.mirrors.ustc.edu.cn

    5.阿里云容器 生成自己的加速地址

    登录:cr.console.aliyun.com

    点击“创建我的容器镜像”,得到专属加速地址。

    创建或修改 /etc/docker/daemon.json 文件,修改为如下形式:

    {
        "registry-mirrors": [
            "http://hub-mirror.c.163.com",
            "https://docker.mirrors.ustc.edu.cn",
            "https://registry.docker-cn.com"
        ]
    }

    1. //重启
    2. service docker restart
    3. //查看是否成功
    4. docker info

    备注:如果是用systemd代替SysV init命令,对照如下:

     在这里插入图片描述

    目前 wsl 是不支持 docker 的守护进程的错误提示:

    Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 

     

     

  • 相关阅读:
    合并单元格
    蓝牙基带的基础
    浙大计算机研究生复试上机考试-2005年畅通工程(考察并查集)
    8. 列表
    java-php-python-基于SpringBoot的桦木加工厂管理系统计算机毕业设计
    精准用户画像!商城用户分群2.0!
    英特尔参与 CentOS Stream 项目
    三板斧的使用、全局配置文件、静态文件的配置、orm介绍
    vue路由详解
    牛客刷题<二>异步复位的串联T触发器
  • 原文地址:https://blog.csdn.net/chaishen10000/article/details/124914492