Docker安装
官方脚本
如果你的服务器在境外可以使用官方脚本安装
curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh
清华大学开源软件镜像站
如果你的服务器在境内可以使用各镜像站加速安装
# 安装依赖
apt-get update
apt-get install ca-certificates curl gnupg
# 信任 Docker 的 GPG 公钥并添加仓库
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
# 安装
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
非root用户加入Docker组
sudo groupadd docker
sudo gpasswd -a ${USER} docker
# 需要重启当前终端
安装Docker Compose
# 安装2.29.7
# 如果你需要安装新版本访问GIthub项目地址查看
# https://github.com/docker/compose/releases
sudo curl -L "https://github.com/docker/compose/releases/download/v2.29.7/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 添加可执行权限并创建软链
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# 查看版本
docker-compose version
Docker Compose version v2.29.7
正文完