debian安装docker
在debian上安装docker和docker-compose
1. 安装docker
切换成root用户,安装一些必要的软件包
1
2
3
4
5
6切换成root用户
sudo -i
安装一些必要的软件包
apt update
apt upgrade -y
apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates然后加入 Docker 的 GPG 公钥和 apt 源(官方和清华的二选一)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16官方的
-----------
获取公钥
curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
添加apt源
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://download.docker.com/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list
清华TUNA的
------------------
获取公钥
curl -sS https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
添加apt源
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list更新系统后即可安装 Docker CE
1
2apt update
apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin使用
docker version
命令检查是否安装成功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
29root@debian ~ # docker version
Client: Docker Engine - Community
Version: 20.10.22
API version: 1.41
Go version: go1.18.9
Git commit: 3a2c30b
Built: Thu Dec 15 22:28:22 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.22
API version: 1.41 (minimum version 1.12)
Go version: go1.18.9
Git commit: 42c8b31
Built: Thu Dec 15 22:26:14 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.14
GitCommit: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
2. 安装docker-compose
因为我们已经安装了 docker-compose-plugin
,所以 Docker 目前已经自带 docker compose
命令,基本上可以替代 docker-compose
:
1 | root@debian ~ # docker compose version |
如果某些镜像或命令不兼容,则我们还可以单独安装 Docker Compose:
我们可以使用 Docker 官方发布的 Github 直接安装最新版本:
1 | 下载docker-compose |