docker - Docker - 为什么运行 ubuntu 的 50 个容器占用与 50x alpine 类似的 RAM?
问题描述
alpine 的图像大小约为 5MB,而 ubuntu - 65MB。那么为什么 RAM 使用率没有明显差异呢?如果我理解正确的话,X 的 docker 镜像会加载到内存中,然后由所有容器共享(从同一个镜像运行)。然后对于每个容器都需要创建一个单独的文件系统等,这就是为什么在这两种情况下内存使用量相似的原因。
我的理解正确吗?
$ cat script.sh
#!/bin/bash
for i in {1..50}
do
docker container run alpine sleep 60 &
done
$ free -mh
total used free shared buff/cache available
Mem: 7.8Gi 1.8Gi 4.5Gi 119Mi 1.4Gi 5.6Gi
Swap: 2.0Gi 103Mi 1.9Gi
$ ./script.sh
$ free -mh
total used free shared buff/cache available
Mem: 7.8Gi 3.4Gi 2.9Gi 122Mi 1.5Gi 4.0Gi
Swap: 2.0Gi 103Mi 1.9Gi
$ vim script.sh
$ free -mh
total used free shared buff/cache available
Mem: 7.8Gi 1.9Gi 4.5Gi 119Mi 1.4Gi 5.6Gi
Swap: 2.0Gi 103Mi 1.9Gi
$ cat script.sh
#!/bin/bash
for i in {1..50}
do
docker container run ubuntu sleep 60 &
done
$ ./script.sh
$ free -mh
total used free shared buff/cache available
Mem: 7.8Gi 3.4Gi 2.9Gi 122Mi 1.5Gi 4.0Gi
Swap: 2.0Gi 103Mi 1.9Gi
解决方案
推荐阅读
- css - 如何将自定义 css 应用于 ionic 4 组件?
- r - stringr 安装错误:命名空间“stringr”由“bibtex”导入,因此无法卸载
- android - When I try to add firebase push notification in the android studio then it shows an error
- javascript - 将索引匹配语句转换为 Google Script
- php - 在 JSON 数组中查找
- flutter - firestore:有没有办法在集合上执行或查询操作?
- python - 如何在python的protobuf中填充StringValue
- php - 允许匿名用户向 MediaWiki 中的特定用户发送电子邮件
- ruby - 在 Ruby 中将摄氏温度转换为华氏温度
- sql - TSQL - 在选择语句中将表名标识为单个或多个表的列,而不将其硬编码为查询的一部分