Docker笔记3 | 在Ubuntu下安装Docker
  NHjqxS4aAIAZ 2023年11月02日 86 0

(3 | 在Ubuntu下安装Docker)

1 支持环境

Docker 支持以下版本的 Ubuntu 操作系统:

Focal 20.04 (LTS) Bionic 18.04 (LTS) Xenial 16.04 (LTS)

2 卸载旧的docker

sudo apt-get remove docker \
docker-engine \
docker.io
  • 旧版本的 Docker 称为 docker 或者 docker-engine
  • 因为我的Ubuntu是新装的,目前未安装docker,可以从卸载命令可以看出来:

在这里插入图片描述

3 安装Docker

3.1 添加HTTPS 传输的软件包以及 CA 证书

  • 因为使用 APT 安装,apt 源使用 HTTPS 以确保软件下载过程中不被篡改:
sudo apt-get update

在这里插入图片描述

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

在这里插入图片描述

3.2 添加软件源的 GPG 密钥

  • 目的是确认所下载软件包的合法性;
# 以后文章建议使用国内源
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

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

在这里插入图片描述

3.3 添加 Docker 软件源

  • sources.list 中添加 Docker 软件源:
$ sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
# 官方源
# $ sudo add-apt-repository \
# "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
# $(lsb_release -cs) \
# stable"

在这里插入图片描述

3.4 安装Docker

  • 使用如下命令:
sudo apt-get update

在这里插入图片描述

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

在这里插入图片描述

3.5 自动安装


$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

在这里插入图片描述

4 Docker启动和验证是否安装ok

4.1 启动Docker

$ sudo systemctl enable docker
$ sudo systemctl start docker

在这里插入图片描述

4.2 docker 用户组建立

  • 将需要使用 docker 的用户加入 docker 用户组;
  • 建议用户组:
$ sudo groupadd docker

在这里插入图片描述

  • 将当前用户加入刚才建议的docker组:
$ sudo usermod -aG docker $USER
  • 使用:cat /etc/group可以查看加入的用户组;

在这里插入图片描述

4.3 验证docker

  • 退出重新登录,输入命令查看:
$ docker run hello-world
  • 输出以下信息表明安装成功了~
noamanelson@noamanelson-Virtual-Machine:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:4e83453afed1b4fa1a3500525091dbfca6ce1e66903fd4c01ff015dbcb1ba33e
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/

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: 语音处理模块 A-09 下一篇: jenkins配置
  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  zzwpYXrztNx3   2023年11月30日   24   0   0 爬虫测试
NHjqxS4aAIAZ
最新推荐 更多