侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

ubuntu20.04系统中安装最新版docker、docker-compose流程步骤

Docker  /  管理员 发布于 3年前   2686

我是在阿里云ecs上的最新ubuntu20.4系统,后面所以教程架构都会基于该版本进行

进入步骤:

0.开始先更新一下源

root@iZwz91cvaakchabbuilxg0Z:~# apt update

1.允许apt通过https使用repository安装软件包 

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

执行命令 (太长了我就...省略了)

root@iZwz984fp76m12whtx8tpgZ:~# sudo apt-get install \
>     apt-transport-https \
>     ca-certificates \
>     curl \
>     gnupg-agent \
>     software-properties-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ca-certificates is already the newest version (20210119~20.04.2).
curl is already the newest version (7.68.0-1ubuntu2.8).
The following package was automatically installed and is no longer required:
  libsasl2-modules
Use 'sudo apt autoremove' to remove it.
...
Do you want to continue? [Y/n] y
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates/main amd64 libpolkit-gobject-1-0 amd64 0.105-26ubuntu1.3 [39.2 kB]
...
Fetched 2,400 kB in 2s (1,410 kB/s)             
Preconfiguring packages ...
(Reading database ... 120915 files and directories currently installed.)
Preparing to unpack .../00-libpolkit-gobject-1-0_0.105-26ubuntu1.3_amd64.deb ...
...
Setting up unattended-upgrades (2.3ubuntu0.1) ...
Creating config file /etc/apt/apt.conf.d/50unattended-upgrades with new version
...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...


2.添加Docker GPG key 及 验证key (国内阿里云版)

root@iZwz984fp76m12whtx8tpgZ:~# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
OK
root@iZwz984fp76m12whtx8tpgZ:~# apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <[email protected]>
sub   rsa4096 2017-02-22 [S]


3.添加repository(国内阿里云版)

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

执行命令

root@iZwz984fp76m12whtx8tpgZ:~# sudo add-apt-repository \
>    "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
>    $(lsb_release -cs) \
>    stable"
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal InRelease
Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates InRelease
Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu focal-backports InRelease                                         
Hit:4 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security InRelease                                          
Get:5 https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal InRelease [57.7 kB]
Get:6 https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages [13.5 kB]
Fetched 71.2 kB in 1s (119 kB/s)
Reading package lists... Done


4.更新源 (...省略)

root@iZwz984fp76m12whtx8tpgZ:~# apt-get update
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal InRelease
Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates InRelease
Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu focal-backports InRelease
Hit:4 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security InRelease
Hit:5 https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal InRelease
Reading package lists... Done


5.安装最新版docker  (...表示省略)

root@iZwz984fp76m12whtx8tpgZ:~# apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libsasl2-modules
Use 'apt autoremove' to remove it.
...
Do you want to continue? [Y/n] y
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal/universe amd64 pigz amd64 2.4-1 [57.4 kB]
...
Processing triggers for systemd (245.4-4ubuntu3.15) ...


6.安装好 看一下docker版本

root@iZwz984fp76m12whtx8tpgZ:~# docker version
Client: Docker Engine - Community
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:42 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0


7.开机启动设置


#看一下docker开机启动状态
root@iZwz984fp76m12whtx8tpgZ:~# systemctl list-unit-files | grep docker
docker.service enabled enabled
docker.socket enabled enabled

#没有的话就要设置,开机启动命令
systemctl enable docker


8.安装docker-compose


#github源超时  大环境是这样 没办法只能换源
curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#执行命令 root@iZwz984fp76m12whtx8tpgZ:~# curl -L "https://get.daocloud.io/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 423 100 423 0 0 165 0 0:00:02 0:00:02 --:--:-- 165
100 23.5M 100 23.5M 0 0 8177k 0 0:00:02 0:00:02 --:--:-- 120M
root@iZwz984fp76m12whtx8tpgZ:~# chmod +x /usr/local/bin/docker-compose
root@iZwz984fp76m12whtx8tpgZ:~# docker-compose --version
Docker Compose version v2.2.2


9.配置阿里云镜像仓库加速


#在/etc/docker/目录下创建daemon.json文件 输入你的加速地址 注意是你的 老铁
root@iZwz984fp76m12whtx8tpgZ:~# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://ft5scn333r.mirror.aliyuncs.com"]
}
#加载信息 重启docker
root@iZwz984fp76m12whtx8tpgZ:~# systemctl daemon-reload root@iZwz984fp76m12whtx8tpgZ:~# systemctl restart docker #看一下是否生效了 ...代表省略 root@iZwz984fp76m12whtx8tpgZ:~# docker info Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.7.1-docker) scan: Docker Scan (Docker Inc., v0.12.0) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.12 Storage Driver: overlay2 ... Registry Mirrors: https://ft5scn3r.mirror.aliyuncs.com/ Live Restore Enabled: false



  • 上一条:
    ubuntu系统中mysql8设置用户远程连接流程步骤
    下一条:
    laravel5.5+框架之环绕中间件实现的流程步骤
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 在docker环境中实现Laravel项目执行定时任务和消息队列流程步骤(0个评论)
    • 在MacBook下laravel项目多php版本docker开发环境配置方案(0个评论)
    • 在docker环境中部署docker部署elk架构流程步骤(1个评论)
    • docker compose跟Dockerfile的区别浅析(0个评论)
    • Ubuntu 22.04系统中安装podman流程步骤(1个评论)
    • 近期文章
    • 智能合约Solidity学习CryptoZombie二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2017-11
    • 2020-06
    • 2021-05
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-11
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2024-03
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客