ubuntu20.04安装docker

3台主机,2台都能正确安装,第三台怎么都安装不成功;

3台主机都是一样的配置和系统;

后来看来是其外网的ip不一样,导致第三台主机可能被Qiang,不过错误只是提示签名不正确,在设置签名时好像没有提示错误,只是在apt update时报错。

后改为阿里的源安装成功了。

以下安装参考(Ubuntu 20.04安装Docker - 知乎)

切换阿里云镜像源安装Docker

1、卸载可能存在的或者为安装成功的Docker版本

sudo apt-get remove docker docker-engine docker-ce docker.io

2、添加阿里云的GPG密钥

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

3、使用以下命令设置存储库

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

4、安装最新版本的Docker(飞速安装)

sudo apt-get update  sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin 

5、验证Docker是否安装成功

-- 查看docker 版本
 docker version 

启动Docker

1、安装完成后,运行如下命令验证 Docker 服务是否在运行

systemctl status docker 

未运行:

2、运行以下命令启动Docker服务

sudo systemctl start docker

3、设置Docker服务在每次开机时自动启动

sudo systemctl enable docker

4、查看docker运行状态

systemctl status docker 

验证Docker是否运行正常

注意:执行下面的命令会下载一个Docker测试镜像,并在容器中执行一个“hello-world”样例程序。

sudo docker run hello-world 

如果你看到类似下方的输出,那么祝贺你,Docker能够正常运行在你的Ubuntu系统中了。

ubuntu@VM-16-10-ubuntu:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:53f1bbee2f52c39e41682ee1d388285290c5c8a76cc92b42687eecf38e0af3f0
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/

### 在 Ubuntu 20.04 LTS 上安装 Docker 为了在 Ubuntu 20.04 LTS 上成功安装 Docker,需遵循一系列特定的操作流程。 #### 更新软件包索引 确保系统的软件包列表是最新的非常重要。这可以通过执行如下命令来完成: ```bash sudo apt update ``` 此操作会刷新本地的APT缓存,从而获取最新的可用版本信息[^1]。 #### 设置Docker仓库 接下来设置用于安装Docker的官方源。首先添加GPG密钥: ```bash curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg ``` 然后添加稳定的Docker APT仓库到 `/etc/apt/sources.list.d/docker.list` 文件中: ```bash echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ``` 上述过程确保了可以从Docker官方渠道安全下载最新版本的应用程序[^3]。 #### 安装Docker引擎 再次更新apt包索引之后,可以正式开始安装Docker社区版(CE)。通过下面这条简单的命令即可实现: ```bash sudo apt-get install docker-ce docker-ce-cli containerd.io ``` 一旦完成以上步骤,Docker应该已经被正确部署到了Ubuntu环境中。 #### 验证安装成果 最后一步是验证新安装的服务是否正常工作。启动一个新的容器实例并测试其连通性是一个不错的选择: ```bash sudo systemctl start docker sudo docker run hello-world ``` 如果一切顺利,则说明Docker已经成功安装并且能够正常使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值