陈伦刚
陈伦刚
发布于 2025-01-07 / 17 阅读
0

Debian12 安装Docker 和 docker-compose

1.升级apt和安装一些必要的软件依赖

apt update && \
apt upgrade -y && \
apt install -y curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates

2.加入 Docker 的 GPG 公钥和 apt 源

curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg]  https://download.docker.com/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list

国内的话就用清华源

curl -sS https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list

3.然后开始安装

apt update && \
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

4.查看是否安装成功

docker version

5.如果是国内源的话可以参考我的另一篇文章

https://chenlungang.com/?p=770

然后修改 /etc/docker/daemon.json 再重启docker即可 systemctl restart docker