Debian手动安装docker、docker compose命令

1、安装 Docker

更新包列表:

sudo apt-get update

安装必要的包:

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

添加 Docker 的官方 GPG 密钥:

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

设置 Docker 的稳定版仓库:

echo "deb [arch=$(dpkg --print-architecture) 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

再次更新包列表:

sudo apt-get update

安装 Docker 引擎:

sudo apt-get install -y docker-ce docker-ce-cli containerd.io

启动 Docker 并设置开机自启动:

sudo systemctl start docker
sudo systemctl enable docker

验证 Docker 安装:

docker --version

2、安装 Docker Compose

下载 Docker Compose 二进制文件:

sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.2/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 安装:

docker-compose –version

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

滚动至顶部