Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman create/run --shm-size doesn't work #1770

Closed
debarshiray opened this issue Nov 7, 2018 · 8 comments
Closed

podman create/run --shm-size doesn't work #1770

debarshiray opened this issue Nov 7, 2018 · 8 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@debarshiray
Copy link
Member

/kind bug

Description

While investigating why /dev/shm wasn't a tmpfs, I found that podman create --shm-size or podman run --shm-size doesn't seem to work as advertised.

$ podman run --interactive --name foo --shm-size 1g --tty fedora /bin/sh
sh-4.4# df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p5  415G   26G  368G   7% /dev/shm

Notice how the size of /dev/shm isn't 1G. In fact, it doesn't have any effect, because the result is the same without --shm-size.

$ podman run --interactive --name foo --tty fedora /bin/sh
sh-4.4# df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p5  415G   26G  368G   7% /dev/shm

I get similar results with podman create, which is what the Silverblue toolbox uses.

(Why doesn't podman mount a tmpfs at /dev/shm by default?)

Output of podman version:

Version:       0.10.1.3
Go Version:    go1.10.4
OS/Arch:       linux/amd64

Output of podman info:

host:
  BuildahVersion: 1.5-dev
  Conmon:
    package: podman-0.10.1.3-3.gitdb08685.fc28.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 1.12.0-dev, commit: 7ab6aac44ec489c04baa7555107ffe668b210b96-dirty'
  Distribution:
    distribution: fedora
    version: "28"
  MemFree: 4783382528
  MemTotal: 16696295424
  OCIRuntime:
    package: runc-1.0.0-57.dev.git9e5aa74.fc28.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.1-dev'
  SwapFree: 4208979968
  SwapTotal: 4208979968
  arch: amd64
  cpus: 4
  hostname: bollard
  kernel: 4.18.16-200.fc28.x86_64
  os: linux
  uptime: 1h 22m 47.86s (Approximately 0.04 days)
insecure registries:
  registries: []
registries:
  registries:
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  ContainerStore:
    number: 1
  GraphDriverName: vfs
  GraphOptions: []
  GraphRoot: /var/home/rishi/.local/share/containers/storage
  GraphStatus: {}
  ImageStore:
    number: 5
  RunRoot: /run/user/1000/run

Additional environment details (AWS, VirtualBox, physical, etc.):

This is a physical laptop running Fedora 28 Silverblue 28.20181105.0, with podman-0.10.1.3-3.gitdb08685.fc28 and 2:runc-1.0.0-57.dev.git9e5aa74.fc28 overlaid on top.

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 7, 2018
@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2018

#  podman run --interactive --name foo1 --tty fedora mount | grep shm
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,context="system_u:object_r:container_file_t:s0:c162,c460",size=64000k)

shm-size is used to modify the default size setting in the mount option. By default we mount at 64000k

#  podman run --interactive --name foo --shm-size 1g --tty fedora mount | grep shm
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,context="system_u:object_r:container_file_t:s0:c761,c1021",size=976564k)

Notice the mount point changed to 976564k

@mheon
Copy link
Member

mheon commented Nov 7, 2018 via email

@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2018

@mheon User NS Allows you to mount tmpfs as long as it is on a directory that you own. But maybe it does not allow you to set the size.

@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2018

@giuseppe Are we not using tmpfs mounted on /dev/shm inside of rootless containers?

@debarshiray
Copy link
Member Author

Yeah, this is when running rootless.

It's not the end of the world because I can work around it with --mount type=tmpfs,destination=/dev/shm.

It has been trickier to mimic the in-kernel tmpfs default of using 50% of RAM instead of 64M. Let's hope my awk incantation to parse /proc/meminfo holds up. :)

@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2018

I do think this is a bug in podman, we should be using a tmpfs for this not physical disk.

debarshiray added a commit to containers/toolbox that referenced this issue Nov 7, 2018
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] containers/podman#1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

#9
debarshiray added a commit to containers/toolbox that referenced this issue Nov 7, 2018
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] containers/podman#1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

#9
debarshiray added a commit to containers/toolbox that referenced this issue Nov 8, 2018
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] containers/podman#1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

#9
@giuseppe
Copy link
Member

there is a PR for this issue: #1777

@rhatdan
Copy link
Member

rhatdan commented Dec 22, 2018

Since this PR has been merged, I am going to close this issue.

@rhatdan rhatdan closed this as completed Dec 22, 2018
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

5 participants