Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何数据持久化? #15

Open
chminsc opened this issue Jun 4, 2024 · 2 comments
Open

如何数据持久化? #15

chminsc opened this issue Jun 4, 2024 · 2 comments

Comments

@chminsc
Copy link

chminsc commented Jun 4, 2024

挂载了opt,mnt,ext目录等,但是重装后在docker-headless中安装的各类程序都丢失了。(即使这三个挂载目录的本地数据没有变化)

如何能使得这部分内容也持久化?

@huapox
Copy link
Member

huapox commented Jun 14, 2024

这个暂无解,容器本身机制是这样,建议结合理解按场景不同 区分注意项,来避免容器内已装过的(非挂载目录)数据丢失:

  • docker/dcp(docker-compose) 场景
    • docker run -d $img 后台运行, 而不是docker run -it --rm $img 临时跑,后者停止则容器被清理
    • dcp create后, dcp start/stop控制启停, 一般禁用dcp down (可认为create建立新容器 即创建了系统盘, 而dcp down则销毁容器 即系统盘也丢了)
  • K8S场景 (它个是一旦节点机器/Pod重启, 即容器重建了)
    • 1.把重要数据放在挂载目录/Volume卷
    • 2.必要的目录做软链接到上1条的目录下;如 先把home拷贝到/_ext下, 再ln -s /_ext/home /home
    • 3.装在/usr下的,对于相关易丢软件: 直接保留一个脚本, 丢了直接新装下即可
    • 4.对应上1条 对于装软件较多, 可基于headless镜像自行定制镜像后, 用装上新程序的定制镜像

@chminsc
Copy link
Author

chminsc commented Jun 14, 2024

定制镜像可能是个好方案

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants