Ubuntu20.04安装Docker

Posted MangataTS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu20.04安装Docker相关的知识,希望对你有一定的参考价值。

文章目录

一、卸载旧版本Docker

在终端输入:(下面也是)

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

二、设置Docker仓库

2.1 更新apt包索引

sudo apt-get update

2.2 安装Docker依赖

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

2.3 添加GPG密钥

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

2.4 设置仓库

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

三、 安装docker Engine-Community

3.1 安装最新版本

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

3.2 安装特定版本

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

四、测试

我们跑一个hello-world 镜像试试

docker run hello-world

这个命令首先会在本地查找有无该容器,如果没有则去docker 的镜像仓库查找
如果反馈如下,则安装成功:

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

接下来就是正式的使用Docker容器化部署了

CSDN 社区图书馆,开张营业! 深读计划,写书评领图书福利~

以上是关于Ubuntu20.04安装Docker的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu20.04 在线安装docker

ubuntu 20.04 以 snap 的方式 安装docker 使用zfs文件系统

Ubuntu20.04安装Docker

Ubuntu20.04安装docker

在Docker中使用TensorFlow(GPU版+Ubuntu 20.04)

ubuntu20.04如何安装nvidia-docker?