Debian 10上安装Docker

如何在Debian 10(Buster)上安装Docker呢?
一、卸载旧版本
Docker 的旧版本被称为 docker,docker.io 或 docker-engine,如果已安装,请卸载它们:
#apt-get remove docker docker-engine docker.io containerd runc
二、设置仓库
1.安装通过 HTTPS 添加新存储库所需的软件包:
#apt update
#apt install apt-transport-https ca-certificates curl software–properties-common gnupg2
2.添加 Docker 的GPG 密钥:
#curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
或#curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | apt-key add -
3.使用以下指令设置稳定版仓库:
#add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release –cs) stable”
或#add-apt-repository “deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian $(lsb_release -cs) stable”
三、安装 Docker Engine-Community(使用 Docker 仓库进行安装)
1.更新apt软件包列表
#apt update
2.安装最新版本Docker Engine-Community 和 containerd或看第3步(安装特定版本)
#apt install docker-ce docker-ce-cli containerd.io
3.安装特定版本的 Docker Engine-Community
Step1.列出您的仓库中可用的版本
#apt-cache madison docker-ce
docker-ce | 5:20.10.3~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:20.10.2~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:20.10.1~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:20.10.0~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.15~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.14~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.13~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.12~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.11~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.10~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.9~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.8~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.7~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages
docker-ce | 5:19.03.6~3-0~debian-buster | https://download.docker.com/linux/debian buster/stable amd64 Packages

Step2.使用第二列中的版本字符串安装特定版本,例如 5:19.03.13~3-0~debian-buster
#apt install docker-ce= docker-ce-cli= containerd.io
4.安装完成后, Docker 服务将自动启动。要验证它输入:
#systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-02-13 22:14:58 CST; 21s ago
Docs: https://docs.docker.com
Main PID: 4922 (dockerd)
Tasks: 13
Memory: 52.0M
CGroup: /system.slice/docker.service
└─4922 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

5.测试
#docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

6.设置加速
#vim /etc/docker/daemon.json
输入以下内容:
{
“registry-mirrors” : [
“http://ovfftd6p.mirror.aliyuncs.com”,
“http://registry.docker-cn.com”,
“http://docker.mirrors.ustc.edu.cn”,
“http://hub-mirror.c.163.com”
],
“insecure-registries” : [
“registry.docker-cn.com”,
“docker.mirrors.ustc.edu.cn”
],
“debug” : true,
“experimental” : true
}
保存退出。
#systemctl restart docker

你可能感兴趣的:(Linux系统专区)