Docker 哲学 - tmpfs 存储

  tem:temporary 暂时的

背景:只有在 linux 有该种方式 

If you're running Docker on Linux, you have a third option: tmpfs mounts. When you create a container with a tmpfs mount, the container can create files outside the container's writable layer.

As opposed to volumes and bind mounts, a tmpfs mount is temporary, and only persisted in the host memory. When the container stops, the tmpfs mount is removed, and files written there won't be persisted.

This is useful to temporarily store sensitive files that you don't want to persist in either the host or the container writable layer.

  • Unlike volumes and bind mounts, you can't share tmpfs mounts between containers.
  • This functionality is only available if you're running Docker on Linux.

在 Docker 中,每个容器都有一个可写层,这是容器在其基础镜像之上创建的。当容器运行并生成数据或更改状态时,这些更改都会写入到这个可写层中。这个可写层是容器的一部分,当容器被删除时,这个层中的所有数据也会被删除。

无论是容器被删除还是容器停止,tmpfs mount 中的数据都会被清除。tmpfs 是一种临时文件系统,它存储在内存中,不会持久化到磁盘。因此,当容器停止或者被删除时,tmpfs mount 中的所有数据都会丢失。这是因为 tmpfs mount 的生命周期与容器的生命周期是绑定的

 

 To use a tmpfs mount in a container, use the --tmpfs flag, or use the --mount flag with type=tmpfs and destination options. There is no source for tmpfs mounts. The following example creates a tmpfs mount at /app in a Nginx container. The first example uses the --mount flag and the second uses the --tmpfs flag.

解释 There is no source for tmpfs mounts

 

 

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-27 18:10:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-27 18:10:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-27 18:10:01       82 阅读
  4. Python语言-面向对象

    2024-03-27 18:10:01       91 阅读

热门阅读

  1. android——【封装】使用建造者方式封装一个类

    2024-03-27 18:10:01       45 阅读
  2. 游戏学(Ludology)探秘

    2024-03-27 18:10:01       40 阅读
  3. leetcode 栈和队列1

    2024-03-27 18:10:01       35 阅读
  4. 数据共享(InheritedWidget)

    2024-03-27 18:10:01       32 阅读
  5. 设计模式之装饰器模式

    2024-03-27 18:10:01       39 阅读
  6. 蓝桥杯真题训练 包子凑数(数论)

    2024-03-27 18:10:01       45 阅读
  7. C++之std::mem_fn使用和实现原理(全)

    2024-03-27 18:10:01       40 阅读
  8. 【力扣】134.加油站

    2024-03-27 18:10:01       39 阅读