惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - x3d

deepin 23 一个可用 mysql-workbench 版本 8.0.36 基于 Maxwell 实现 MySQL 数据实时迁移到 Mongodb intel ax203/ax201 无线网卡驱动 firmware 居然有问题 Direct firmware load for iwlwifi-bz-b0-hr-b0-94.ucode failed with error -2 在安卓平板上搭建 webdav 服务 近期不要选aliyun cloud linux 镜像 一点 PHP 中优雅的将JSON/XML/YAML 等数据反序列化成指定的类对象 开始收割了 PHP Composer 虚拟依赖包 - 实现按需载入钉钉对应功能模块的 php sdk 盘点之原地踏步三 盘点之原地踏步二 盘点之原地踏步一:weui 的一点探索 apijson 初探 Apache Synapse ESB erupt api Think3 ORM 《超文本和超链接》的时间线整理 MEAF框架概念检索工具 现代企业架构框架MEAF初次解读
本地开发环境 通过Podman 手动从头搭建 Ubuntu 容器镜像
x3d · 2025-05-25 · via 博客园 - x3d

在接触的所有项目中,应用容器化技术,不一定有绝对必要,但是最近发现反而在本地开发环境是有必要性的。

回到过去的方式,是通过重新体验过去发生的事情。重新将Linux桌面做主力开发环境,配置过程中,各种肌肉记忆就会逐渐跳出来,比如 x11桌面下,fcitx 输入法冲突问题.并加固了一些经验:桌面是桌面,服务器是服务器;如果分开两个维度来看,似乎思路清晰了一些;桌面需求,是全方位的,办公、开发者、学习等;服务器,则只要一些固定的代码运行环境。

因为所维护的各个项目时间跨度太长,语言的各种版本需要处于共存状态。Linux环境跑 Docker 之类的容器也很方便,只是容器镜像的下载不太可靠,一直卡在这个障碍上。当有需求时,就会认真思考这个问题。基于简单的逻辑,各种镜像的源头总得是有人从头构建出来的,查了一下确定是可以的,叫做 From Scratch 的方式。

目前主力开发机上运行的是Fedora,自带了 Podman,类Docker的方案。

下载一个基础镜像;Debian、Ubuntu、ArchLinux 等

Docker Debain: https://docker.debian.net/

以 Ubuntu 为例,下载 Base 镜像 到本地目录,

https://mirrors.ustc.edu.cn/ubuntu-cdimage/ubuntu-base/releases/24.04.2/release/

在镜像所在目录,创建 Dockerfile 文件,添加相关基础内容:

From scratch
ADD ubuntu-base-24.04.2-base-amd64.tar.gz /

CMD ["/bin/bash"]

然后就可以 执行命令创建本地容器镜像了。

podman build -t ubuntu-base:24.04.2 .

执行结果:


STEP 1/3: FROM scratch
STEP 2/3: ADD ubuntu-base-24.04.2-base-amd64.tar.gz /
--> 1bd63ef447bf
STEP 3/3: CMD ["/bin/bash"]
COMMIT ubuntu-base:24.04.2
--> fa6d199abb3f

Successfully tagged localhost/ubuntu-base:24.04.2
fa6d199abb3ff03cb52c01363ed649ead402fb20045b5850787356539927c969

查看一下镜像情况:

podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/ubuntu-base        24.04.2       fdc0b8a54b14  3 days ago  75.1 MB

验证镜像

podman run --name ubuntu-24 localhost/ubuntu-base:24.04.2 echo "hello, ubuntu"

后面的流程就是常规的了。