Docker系列(3) ubuntu docker安装

1. 版本介绍

Docker 的旧版本被称为 docker,docker.io 或 docker-engine ,目前版本分为docker-ce(社区版),docker-ee(企业版)
系统版本要求:
Docker Engine-Community 支持以下的 Ubuntu 版本:

  • Xenial 16.04 (LTS)
  • Bionic 18.04 (LTS)
  • Cosmic 18.10
  • Disco 19.04
  • 其他更新的版本……

2. 安装步骤

0.卸载旧版本

dd@ubuntu04: sudo apt-get remove docker docker-engine docker.io containerd runc

1.更换国内软件源,推荐中国科技大学的源,稳定速度快(可选)

dd@ubuntu04:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
dd@ubuntu04:~$ sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
dd@ubuntu04:~$ sudo apt update

报错:

Err:1 http://cn.mirrors.ustc.edu.cn/ubuntu bionic InRelease
  Connection failed [IP: 202.141.176.110 80]
Err:2 http://cn.mirrors.ustc.edu.cn/ubuntu bionic-updates InRelease
  Connection failed [IP: 202.141.176.110 80]
Err:3 http://cn.mirrors.ustc.edu.cn/ubuntu bionic-backports InRelease
  Connection failed [IP: 202.141.176.110 80]
Err:4 http://cn.mirrors.ustc.edu.cn/ubuntu bionic-security InRelease
  Connection failed [IP: 202.141.176.110 80]
Reading package lists... Done
W: Failed to fetch http://cn.mirrors.ustc.edu.cn/ubuntu/dists/bionic/InRelease  Connection failed [IP: 202.141.176.110 80]
W: Failed to fetch http://cn.mirrors.ustc.edu.cn/ubuntu/dists/bionic-updates/InRelease  Connection failed [IP: 202.141.176.110 80]
W: Failed to fetch http://cn.mirrors.ustc.edu.cn/ubuntu/dists/bionic-backports/InRelease  Connection failed [IP: 202.141.176.110 80]
W: Failed to fetch http://cn.mirrors.ustc.edu.cn/ubuntu/dists/bionic-security/InRelease  Connection failed [IP: 202.141.176.110 80]

原因不详,相关镜像没问题(也切换过阿里云镜像),dns也进行l了过配置,仍然无法解决 目前采用从一个没问题的ubuntu01(一样的操作,为啥这个ok暂不清楚)scp /ect/apt所有内容到ubuntu04

2.安装需要的包

dd@ubuntu04:~$ sudo apt install apt-transport-https ca-certificates software-properties-common curl

3.添加 GPG 密钥,并添加 Docker-ce 软件源,这里还是以中国科技大学的 Docker-ce 源为例

dd@ubuntu04:~$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
dd@ubuntu04: sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable"

4.添加成功后更新软件包缓存

dd@ubuntu04:~$ sudo apt update

5.安装 Docker-ce

dd@ubuntu04:~$ sudo apt-get install docker-ce

6.设置开机自启动并启动 Docker-ce(安装成功后默认已设置并启动,可忽略)

dd@ubuntu04:~$ sudo systemctl enable docker
dd@ubuntu04:~$ sudo systemctl start docker

7.测试运行

dd@ubuntu04:~$ sudo docker run hello-world
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/

8.添加当前用户到 docker 用户组,可以不用 sudo 运行 docker(可选)

dd@ubuntu04:~$ sudo groupadd docker
dd@ubuntu04:~$ sudo usermod -aG docker $USER
dd@ubuntu04:~$ newgrp docker     #更新用户组

9.测试添加用户组(可选)

dd@ubuntu04:~$ docker run hello-world

3. 参考文献

[1] Ubuntu Docker 安装

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值