0%

Debian 安装 Docker & Docker Compose

安装 Docker

正常安装

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

镜像安装

# 清理:
sudo apt remove -y docker docker-engine docker.io
# 安装依赖:
sudo apt 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 update -y
sudo apt install -y docker-ce

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

设置加速镜像

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 并设置开机自启

sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker

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

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

export LATEST_VERSION=$(curl "https://api.github.com/repos/docker/compose/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
curl -o ./docker-compose -L https://github.com/docker/compose/releases/download/$LATEST_VERSION/docker-compose-linux-`uname -m`
sudo chmod +x ./docker-compose
sudo mv ./docker-compose /usr/local/bin/docker-compose

若下载缓慢请使用 curl --proxy socks5://ip:port -L {path} 参数设置代理.

  • 本文作者: 6x
  • 本文链接: https://6xyun.cn/article/137
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-ND 许可协议。转载请注明出处!