Debian11之Docker稳定版本安装

官方地址
常用操作,参考这篇文章

卸载历史版本

apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
apt-get remove docker docker-engine docker.io containerd runc
rm -rf /etc/docker && rm -rf /usr/libexec/docker && rm -rf /var/lib/docker && rm -rf /var/lib/containerd && rm -rf /etc/apt/keyrings
whereis docker # 确保没有和docker相关的文件

Install using the Apt repository

1、Set up Docker’s Apt repository

apt-get update && apt-get install ca-certificates curl gnupg install lsb-release apt-transport-https software-properties-common
  • 基于docker地址(慢)
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
  • 基于aliyun地址(快)
# curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

2、Add the repository to Apt sources

  • 基于docker地址(慢)
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
  • 基于aliyun地址(快)
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] http://mirrors.aliyun.com/docker-ce/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update

3、安装指定版本 Docker

chmod a+r /etc/apt/keyrings/docker.gpg && apt-get update
apt-cache madison docker-ce | awk '{ print $3 }' # 查询存储库中可用的版本

在这里插入图片描述

VERSION_STRING=5:24.0.6-1~debian.11~bullseye # 指定版本号
# docker-ce:Docker守护进程
# docker-ce-cli CLI工具用来远程控制Docker守护进程‎
# docker-compose和docker-compose-plugin:轻松、高效的管理容器,它是一个用于定义和运行多容器 Docker 的应用程序工具
apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

4、安装校验

docker --version # 检查安装版本:Docker version 24.0.6, build ed223bc
docker info # 基本信息
Client: Docker Engine - Community
 Version:    24.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
 runc version: v1.1.9-0-gccaecfc
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.10.0-21-amd64
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.736GiB
 Name: base
 ID: 53f56847-8bd4-4eb5-bb56-ed552643a134
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

5、开机自启

systemctl enable docker && systemctl restart docker && systemctl status docker

6、自定义阿里云镜像

登陆阿里云控制台

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

配置Docker运行时镜像加速器

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://lixing.5fl2j66y.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload && systemctl restart docker && docker info # 基本信息

在这里插入图片描述

配置Containerd运行时镜像加速器

Containerd通过在启动时指定一个配置文件夹,使后续所有镜像仓库相关的配置都可以在里面热加载,无需重启Containerd

  • 编辑 /etc/containerd/config.toml 文件
# 若有 plugins."io.containerd.grpc.v1.cri".registry,则在下面添加 config_path = "/etc/containerd/certs.d"
# 若没有则可以在任意地方写入如下内容:
[plugins."io.containerd.grpc.v1.cri".registry]
  config_path = "/etc/containerd/certs.d"
# 在 config_path(/etc/containerd/certs.d)路径中创建 docker.io/hosts.toml 文件,添加如下内容
server = "https://registry-1.docker.io"
[host."https://lixing.5fl2j66y.mirror.aliyuncs.com"]
  capabilities = ["pull", "resolve", "push"]
# 检查配置文件中是否有原有mirror相关的配置,如果有则需要以下删除配置【这个方式已经过时,后面可能会失效】
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
    endpoint = ["https://registry-1.docker.io"]
systemctl restart containerd # 重启Containerd,如果失败则执行 journalctl -u containerd 查看具体原因
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大能嘚吧嘚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值