0%

Debian 11 安装 Docker & Docker Compose

安装 Docker

正常安装

https://docs.docker.com/engine/install/debian/#install-using-the-repository

镜像安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 清理:
sudo apt-get remove -y docker docker-engine docker.io
# 安装依赖:
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
# 信任 Docker 的 GPG 公钥:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
# 添加软件仓库:
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
$(lsb_release -cs) \
stable"
# 安装
sudo apt-get update -y
sudo apt-get install -y docker-ce

https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

设置加速镜像

1
2
3
4
5
6
7
8
9
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://ustc-edu-cn.mirror.aliyuncs.com/",
"https://hub-mirror.c.163.com/"
]
}
EOF

重启 docker 并设置开机自启

1
2
3
sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker

允许运行普通账号直接执行 docker 命令

1
2
3
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

安装 Docker Compose

1
2
3
sudo curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ./docker-compose
sudo chmod +x ./docker-compose
sudo mv ./docker-compose /usr/local/bin/docker-compose
  • 本文作者: 6x
  • 本文链接: https://6xyun.cn/article/137
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-ND 许可协议。转载请注明出处!