bibi45

2021-03-14 | DevOps 中文

Docker 数据卷:容器可替换,状态应独立

bibi45

应用容器适合无状态运行;需要保留的数据必须有明确的存储与备份边界。

This article is currently available in Chinese. The language switch changes the site interface; the original text is shown below.

容器文件系统会随着容器删除而消失。数据库、用户上传和长期任务输出不应只存在于可写容器层。

docker volume create app-data
docker run --mount source=app-data,target=/var/lib/app image:tag

开发环境可使用 bind mount;生产状态应选择具有访问控制、备份和恢复计划的数据库或对象存储。数据卷不是备份策略本身。

© 2026 bibi45. All rights reserved.

Built as a static, Git-owned site.