安装docker和docker-compose

2024-09-06 12:19:33 浏览数 (2)

前言

centos7上的软件版本都比较旧了,尝试一下debian。

Debian11

安装docker

代码语言:javascript复制
# 依赖
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common

# 公钥
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg


# 添加源
## 官方源
echo   "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian 
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# 安装
apt-get update -y
apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

安装docker-compose

代码语言:javascript复制
export LATEST_VERSION=$(wget -qO- -t1 -T2 "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 -L https://github.com/docker/compose/releases/download/$LATEST_VERSION/docker-compose-linux-`uname -m` > ./docker-compose
chmod  x ./docker-compose
mv ./docker-compose /usr/local/bin/docker-compose

ubuntu

版本信息:Ubuntu 22.04 LTS

代码语言:javascript复制
# 源
apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg


echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# 安装
apt update && apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose

# 验证
docker --version
docker-compose --version

设置国内源

代码语言:javascript复制
vim /etc/docker/daemon.json
{
    "registry-mirrors": [
        "https://mirror.ccs.tencentyun.com"
    ]
}

0 人点赞