启动时修改docker的共享内存大小
docker run -it --shm-size="1g" ubuntu
docker修改运行时容器的shm值
- 进入容器中,通过查看shm的大小
df -h
可以看到默认的shm只有64MB
-
使用sudo权限
-
停止docker服务
systemctl stop docker
- 然后根据容器的id, 进入
cd /var/lib/docker/containers/<container-id>
修改hostconfig.json中的ShmSize值,这个值的单位是byte,例如如果要扩为1GB,就填1073741824。
然后保存。
- 重启docker服务和容器
systemctl restart docker
docker restart <container-id>