20分钟入门 - Docker教程

本文章只提供快速入门教程,旨在帮助新手们(包括我自己)快速入门一个相关知识,不包含详细的知识点以及高级的技术用法。如有需要,可自行查找更加详细的资料。

安装

博主的系统是Ubuntu 18.04.1, 安装的是Docker19.03.6, 如果是其他系统,或在想安装指定的Docker版本,可以参考Docker的官方教程

删除旧版本Docker

Docker的就版本可能叫dockerdocker.io、 或docker-engine,在安装最新版之前必须将其删除,以免引起不必要的麻烦。

$ sudo apt-get remove docker docker-engine docker.io containerd runc

安装Docker Engine - Community

  1. 更新APT

    $ sudo apt-get update
    
  2. 安装下面几个包,允许apt通过HTTPS使用仓库

    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common
    
  3. 添加官方的GPG密钥

    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

    添加完后验证是否添加正确

    $ sudo apt-key fingerprint 0EBFCD88
        
    pub   rsa4096 2017-02-22 [SCEA]
          9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
    sub   rsa4096 2017-02-22 [S]
    
  4. 设置使用stable版本的仓库

    $ sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    
  5. 安装

    $ sudo apt-get update
    $ sudo apt-get install docker-ce docker-ce-cli containerd.io
    
  6. 跑个"hello world"来验证一下是否安装正确

    $ sudo docker run hello-world
    

    如果你出现下面这种情况

    Unable to find image 'hello-world:latest' locally
    docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout.
    See 'docker run --help'.
    

    不要慌,再跑一次,你会发现神奇的事情发生。

    $ sudo docker run hello-world
    
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    1b930d010525: Pull complete 
    Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    ......
    

    自此,安装完成?

    什么?还是不行?

    那你只能看看Docker的官方教程。注意你的系统系统版本,需要安装的Docker版本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值