Ubuntu 安装docker&docker-compose服务
示例Ubuntu服务器版本: Ubuntu 22.10
移除旧版本 docker
sudo apt-get remove docker docker-engine docker.io containerd runc
更新 apt 包索引与升级
sudo apt-get update
sudo apt-get upgrade
安装 apt 依赖包,用于通过HTTPS来获取仓库:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
添加Docker的官方GPG密钥
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
#通过搜索指纹的后8个字符,验证您现在是否拥有带有指纹的密钥。
sudo apt-key fingerprint 0EBFCD88
> pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
设置稳定版仓库
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
$(lsb_release -cs) \
stable"
如果要使用 Docker 作为非 root 用户,则应考虑使用类似以下方式将用户添加到 docker 组
sudo usermod -aG docker your-user
docker pull镜像加速源配置,docker-compose和docker共用一个
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://fudfkcar.mirror.aliyuncs.com"]
}
EOF
安装最新版本的docker和docker compose(默认不指定版本)
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose
安装docker和docker compose(指定版本)
仓库中列出可用版本
apt-cache madison docker-ce
> docker-ce | 5:24.0.5-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:24.0.4-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:24.0.3-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:24.0.2-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:24.0.1-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:24.0.0-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.6-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.5-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.4-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.3-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.2-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.1-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:23.0.0-1~ubuntu.22.10~kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:20.10.24~3-0~ubuntu-kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:20.10.23~3-0~ubuntu-kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:20.10.22~3-0~ubuntu-kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
docker-ce | 5:20.10.21~3-0~ubuntu-kinetic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu kinetic/stable amd64 Packages
指定版本安装
#docker
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
#docker-compose
#按版本拉取
sudo curl -L https://github.com/docker/compose/releases/download/{版本}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version