当前位置: 首页 > news >正文

ubuntu系统版本安装docker容器

docker官网链接

https://www.docker.com/

安装要求

需要静态地址,以及需要dns地址。

vim /etc/netplan/50-cloud-init.yaml
network:ethernets:ens33:addresses:- 192.168.6.121/24nameservers:addresses:- 223.5.5.5- 223.6.6.6- 8.8.8.8- 8.8.4.4search:- jingyu.cnroutes:-   to: defaultvia: 192.168.6.16version: 2
cat /etc/resolv.conf
options edns0 trust-ad
#search 223.5.5.5 223.6.6.6 8.8.8.8 8.8.4.4
nameserver 223.5.5.5
nameserver 223.6.6.6
nameserver 8.8.8.8
nameserver 8.8.4.4

建议更改配置国内原(避免等待时间过长)

阿里源

https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11XHo5rx

选择自己的系统版本复制粘贴到/etc/apt/source.list文件中。(将之前默认的全部删除)

vim /etc/apt/source.list

ubuntu 22.04 LTS (jammy) 配置如下

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

ubuntu 24.04 (noble) 配置如下 

deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

更新apt源

apt -y update

安装docker

如果之前安装docker ,在安装docker engine之前需要卸载任何冲突的软件包。

如果是第一次安装则可以跳过。

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

apt-get进行安装

apt-get update
apt-get -y install ca-certificates curl gnupg

gnupg 是 GNU Privacy Guard 的缩写,它是一个完整的和免费的PGP替换工具,用于加密、签名以及验证数据和通信。在安装Docker的过程中,gnupg(或其变体如 gnupg2)主要用于安全地添加和管理Docker官方仓库的GPG密钥,以确保你下载的Docker软件包是来自官方且未被篡改过的。

# step 2: 信任 Docker 的 GPG 公钥

选择符合自己系统版本的信息

24.04以下版本(不包括24.04版本)

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
最新版本(24.04系统版本及以上版本)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Step 3: 写入软件源信息

24.04以下版本(不包括24.04版本)

echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get -y update
最新版本(24.04系统版本及以上版本)
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

 24.04信息为docker官网的下载docker软件时由于在国外下载较慢,建议使用加速器下载,便可下载成功。

sudo apt-get -y update

# Step 4: 安装Docker

sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

如果需要安装特定的版本docker engine需要先列出存储库中的可用版本:

# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# apt-cache madison docker-ce
#   docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
#   docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# Step 2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]
#VERSION_STRING=5:27.4.0-1~ubuntu.24.04~noble
#sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

添加docker镜像

cat >/etc/docker/daemon.json<< jingyu
{"registry-mirrors": ["https://docker.1ms.run","https://doublezonline.cloud","https://dislabaiot.xyz","https://docker.fxxk.dedyn.io","https://dockerpull.org","https://docker.unsee.tech","https://hub.rat.dev","https://docker.1panel.live","https://docker.nastool.de","https://docker.zhai.cm","https://docker.5z5f.com","https://a.ussh.net","https://docker.udayun.com","https://hub.geekery.cn"]
}
jingyu

通过运行映像来验证安装是否成功:hello-world

sudo docker run hello-world


http://www.mrgr.cn/news/80652.html

相关文章:

  • Kubeadm+Containerd部署k8s(v1.28.2)集群(非高可用版)
  • windows11 24H2 CSOL 闪退问题解决办法
  • Java通过反射破坏单例模式
  • Compose IO
  • Linux介绍与安装CentOS 7操作系统
  • JS实现简单的前端分页功能
  • Avalonia 开发环境准备
  • asp.net core发布配置端口号,支持linux
  • 使用qemu搭建armv7嵌入式开发环境
  • matlab绘图时设置左、右坐标轴为不同颜色
  • JVM性能优化一:初识内存泄露-内存溢出-垃圾回收
  • Linux Shell 脚本编程基础知识篇
  • 【蓝桥杯】46195.水仙花数
  • ARM学习(38)多进程多线程之间的通信方式
  • Visual Studio 2022 QT5.14.2 新建项目无法打开QT的ui文件,出现闪退情况
  • [spring]XML标签<bean>的二级标签
  • WPF ControlTemplate 控件模板
  • 【递归,搜索与回溯算法】穷举 vs 暴搜 vs 深搜 vs 回溯 vs 剪枝算法入门专题详解
  • “年轻科技旗舰”爱玛A7 Plus正式发布,全国售价4999元
  • AMS1117芯片驱动电路·降压芯片的驱动电路详解