Ubuntu 20.04 安装 docker 详解

直接上手开干!

前言

此文档查看官网的doc文档Install Docker Engine on Ubuntu | Docker Documentation

步骤

1. 卸载旧的版本

旧版本的Docker过去的名字 dockerdocker.io, 或 docker-engine. 卸载任何这类较早版本之前,企图安装 一个新的版本:

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

2.安装相应的apt依赖

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

注意:若上述失败请依次安装

sudo apt-get install  apt-transport-https 
sudo apt-get install  ca-certificates 
sudo apt-get install  curl 
sudo apt-get install  gnupg-agent 
sudo apt-get install  software-properties-common

3.配置阿里云的gpg

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

4.配置阿里云的docker镜像,设置一个稳定的仓库

注意:如果不知道执行命令查看::vi  /etc/apt/sources.list   最开始的地方会有“ Release amd64 ”字样,我的是这个!!!

x86_64/amd64:

sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

armhf:

sudo add-apt-repository "deb [arch=armhf] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

arm64:

sudo add-apt-repository "deb [arch=arm64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable”

5.再更新一次 apt

sudo apt-get update

6.安装最新的 docker

sudo apt-get install docker-ce docker-ce-cli containerd.io

7.运行hello-world

 sudo docker run hello-world

出现以下为启动正常!!!

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:94ebc7edf3401f299cd3376a1669bc0a49aef92d6d2669005f9bc5ef028dc333
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/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值