一 Docker安装
1.1 安装必要的一些系统工具
sudo apt-get update -y && sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
1.2 安装GPG证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
1.3 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
1.4 更新并安装Docker-CE
sudo apt-get update -y
sudo apt-get install docker-ce -y
1.5 启动Dokcer并设置开机启动
sudo systemctl start docker && sudo systemctl enable docker
1.6 安装校验
ubuntu@jnpf-devops-jenkins:~$ sudo docker version
Client: Docker Engine - Community
Version: 24.0.5
API version: 1.43
Go version: go1.20.6
Git commit: ced0996
Built: Fri Jul 21 20:35:18 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.5
API version: 1.43 (minimum version 1.12)
Go version: go1.20.6
Git commit: a61e2b4
Built: Fri Jul 21 20:35:18 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
1.7 配置镜像加速
1.7.1 创建docker目录
sudo mkdir -p /etc/docker
1.7.2 配置镜像加速
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://ippu0kr0.mirror.aliyuncs.com"]
}
EOF
1.7.3 重载配置并重启Docker
sudo systemctl daemon-reload && sudo systemctl restart docker
二 docker-compose安装
2.1 下载docker-compose
sudo apt install docker-compose
2.2 赋予权限
sudo chmod +x /usr/bin/docker-compose
2.3 检查安装的 Docker-Compose 版本
docker-compose -v
# 正常的输出结果如下
Docker Compose version v2.21.0