Ubuntu22.04 安装Docker

安装docker

# 更新
sudo apt update

# 安装必要的证书并允许 apt 包管理器使用以下命令通过 HTTPS 使用存储库:
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release

# 运行下列命令添加 Docker 的官方 GPG 密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/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/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# 更新 Ubuntu 源列表:
sudo apt update

# 安装指定版本的docker
# 检查可以安装的docker版本库
apt-cache madison docker-ce

# 挑选上面列表中的任何版本进行安装
sudo apt install docker-ce=5:20.10.16~3-0~ubuntu-jammy docker-ce-cli=5:20.10.16~3-0~ubuntu-jammy containerd.io -yq

# 查看docker是否运行
systemctl status docker

# 查看版本
docker version

# 测试
 docker run -it ubuntu bash

添加阿里镜像加速

cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ],
  "registry-mirrors": ["https://uyah70su.mirror.aliyuncs.com"]
}
EOF


systemctl restart docker
systemctl status docker

此处的镜像加速仓库地址获取方法:
阿里云找镜像加速器的地址
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
在这里插入图片描述

安装Docker-compose

Docker-compose在GitHub上的地址:https://github.com/docker/compose/releases

sudo curl -L "https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose version

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值