Ubuntu 下 Docker安装 2024

Ubuntu 下 Docker安装 2024

安装

1.卸载老版本

bash 复制代码
 sudo apt-get remove docker docker-engine docker.io containerd runc

2.更新apt包索引

bash 复制代码
 sudo apt-get update

3.安装必要工具包

bash 复制代码
 sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

4.添加Docker GPG秘钥

推荐使用国内源

bash 复制代码
sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

5.配置仓库源

推荐使用国内源

bash 复制代码
sudo add-apt-repository \
      "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
      $(lsb_release -cs) \
      stable"

6.安装Docker Engine

bash 复制代码
# 更新apt包索引
sudo apt-get update

# 安装docker
sudo apt-get install docker-ce docker-ce-cli containerd.io

7.启动docker

bash 复制代码
sudo systemctl enable docker
sudo systemctl start docker

国内镜像源下架的解决办法

1.修改文件 /etc/docker/daemon.json

(如果不存在则创建)

bash 复制代码
sudo mkdir -p /etc/docker

2.换源

bash 复制代码
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
 	"https://dockerpull.com",
	"https://docker.1panel.live",
	"https://dockerproxy.cn",
	"https://docker.hpcloud.cloud"
  ]
}
EOF

3.查看是否换源成功

bash 复制代码
docker info

4.重启

bash 复制代码
sudo systemctl daemon-reload
sudo systemctl restart docker
相关推荐
Sumlll_21 小时前
Ubuntu系统下QEMU的安装与RISC-V的测试
linux·ubuntu·risc-v
猫头虎21 小时前
2025最新OpenEuler系统安装MySQL的详细教程
linux·服务器·数据库·sql·mysql·macos·openeuler
晚风吹人醒.1 天前
SSH远程管理及访问控制
linux·运维·ssh·scp·xshell·访问控制·远程管理
Uncertainty!!1 天前
Linux多用户情况下个别用户输入密码后黑屏
linux·远程连接
necessary6531 天前
使用Clion查看linux环境中的PG源码
linux·运维·服务器
小猪佩奇TONY1 天前
Linux 内核学习(14) --- linux x86-32 虚拟地址空间
linux·学习
Lam㊣1 天前
Centos 7 系统docker:更换镜像源
linux·docker·centos
claider1 天前
Vim User Manual 阅读笔记 User_04.txt Making small changes 作微小改动
vim
FL16238631291 天前
win11+WSL+Ubuntu-xrdp+远程桌面闪退+黑屏闪退解决
linux·运维·ubuntu
石头5301 天前
Kubernetes监控全栈解决方案:从零搭建Prometheus+Grafana监控体系
linux