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

 

 

  • 21
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值