当前位置:   article > 正文

Docker笔记3 | 在Ubuntu下安装Docker_docker下载 ubuntu

docker下载 ubuntu

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
  • 1
  • 2
  • 3
  • 旧版本的 Docker 称为 docker 或者 docker-engine
  • 因为我的Ubuntu是新装的,目前未安装docker,可以从卸载命令可以看出来:

在这里插入图片描述

3 安装Docker

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

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

在这里插入图片描述

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

在这里插入图片描述

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
-
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

在这里插入图片描述

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"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在这里插入图片描述

3.4 安装Docker

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

在这里插入图片描述

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

在这里插入图片描述

3.5 自动安装


$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
  • 1
  • 2
  • 3

在这里插入图片描述

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

4.1 启动Docker

$ sudo systemctl enable docker
$ sudo systemctl start docker
  • 1
  • 2

在这里插入图片描述

4.2 docker 用户组建立

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

在这里插入图片描述

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

在这里插入图片描述

4.3 验证docker

  • 退出重新登录,输入命令查看:
$ docker run hello-world
  • 1
  • 输出以下信息表明安装成功了~
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/

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/776893
推荐阅读
相关标签
  

闽ICP备14008679号

        
cppcmd=keepalive&