文章摘要
GPT 4

一、安装Docker

1.更新系统软件包

1
2
sudo apt update
sudo apt upgrade

2.安装所需的依赖库和工具:

1
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release

3.添加Docker官方GPT秘钥:

1
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

4.设置Docker稳定版存储库

1
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

5.更新软件包索引:(这一步可要可不要,因为前面已经执行了)

1
sudo apt update

6.安装Docker引擎:

1
sudo apt install docker-ce docker-ce-cli containerd.io

7.添加当前用户到Docker组:

1
sudo usermod -aG docker $USER
安装成功以后提示:
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
root@Debian:~# docker version #查看版本
Client: Docker Engine - Community
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:52:17 2023
OS/Arch: linux/amd64
Context: default

Server: Docker Engine - Community
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:52:17 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0

二、安装Docker Compose

下载 Docker Compose 二进制文件:

1
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

添加执行权限:

1
sudo chmod +x /usr/local/bin/docker-compose

验证Docker Compose是否安装成功:

1
docker-compose version