Skip to content

sysctl tunables #4717

Closed
Closed

Description

@q53

When launching a dockerised process as root it is possible to execute some kind of init script to set sysctl values. But setting right ulimits is actually need the -privileged flag.
When run as user (-u flag) is there a way to do subj? I did not find any in docs.
Setting of any other stuff (like /dev/shm size, #2606) would be great.

Activity

  1. q53 commented on Apr 7, 2014

    @q53
    Author

    Any comments?

  2. changed the title [-]Correct way to set sysctl,ulimit when runnnig as user.[/-] [+]set ulimit / file limit / nproc limit[/+] on May 20, 2014
  3. changed the title [-]set ulimit / file limit / nproc limit[/-] [+]set ulimit / file limit / nproc limit / sysctl[/+] on May 20, 2014
  4. alexlarsson commented on May 22, 2014

    @alexlarsson
    Contributor

    It would be nice to allow users to change these limits, but we also probably want to default to set them to something lower, as to be able to handle many containers the docker daemon is generally set to a very large ulimit on nr of open files, which then gets inherited by all containers.

  5. alexlarsson commented on May 22, 2014

    @alexlarsson
    Contributor

    In particular, FD_SETSIZE is set to 1024 by default in most built linux apps, which breaks if the ulimit for nr of open files is > 1024

  6. jeffbaier commented on Jun 14, 2014

    @jeffbaier

    I would like to be able to change some network parameters at runtime without running the container in privileged mode. For example -

    root@d7cbfe215281:~# echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
    -bash: /proc/sys/net/ipv4/icmp_echo_ignore_all: Read-only file system
    
  7. jhulten commented on Jul 14, 2014

    @jhulten

    In order to run a chef server in a container I need to run postgres, which means I need to tune shmmax and shmall. The chef omnibus installer starts postgres to add base users and tables, which I cannot do right now since sysctl requires privileged mode and you can't have privileged build steps.

  8. tinytelly commented on Jul 15, 2014

    @tinytelly

    does anyone know the current status of this.....its a big deal that I can no longer run 'sysctl -w kernel.shmmax=1067108864' inside a container.......and has literally stopped my Docker use case from working going from 0.11.1 to 1.0.0....the default value that is populated is 32mb and is useless (amazon ec2, default redhat ami)

  9. mcieslik-mctp commented on Jul 16, 2014

    @mcieslik-mctp

    Same "kernel.shmmax" issue. Even when kernel.shmmax is set on the host prior to running a container (ubuntu 14.04 based). The limit inside the container is much lower (I don't know where the defaults come from). I can only use privileged mode to change it.

  10. timcash commented on Sep 20, 2014

    @timcash

    Is there a work around for setting ulimit -n . I have tried some of the suggestions on the google-group but no luck.

    cat /proc/$(my_docker_pid>)/limits | grep files
    shows that setting ulimit -n 65000 and restarting the daemon works but none of the containers I start after this seem to inherit that. I need this to work so I can run things like a database in a docker file

    UPDATE:
    so when I use nsenter from the host ulimit -a is reporting correctly.

    when I use google's gcloud compute ssh --container my_container to ssh into the container it does not report correctly

  11. changed the title [-]set ulimit / file limit / nproc limit / sysctl[/-] [+]set ulimit / file limit / nproc limit / sysctl tunables[/+] on Oct 10, 2014
  12. thockin commented on Oct 17, 2014

    @thockin
    Contributor

    This is starting to matter. Having control of ulimits seems like something docker needs to handle first-class.

  13. freman commented on Oct 25, 2014

    @freman

    +1

    We too would find it most useful to be able to set sysctl environment.

    We understand that security dictates locking /proc down but if we could send sysctl things to set via the docker command line

    i.e. docker run --sysctl net.core.somaxconn=1024 image

    This would be so awsome.

  14. gdm85 commented on Oct 27, 2014

    @gdm85
    Contributor

    The approach proposed on StackOverflow is a security nightmare.

    I made some research and seems like this feature could be added in HostConfig and be applied right before CAP_SYS_ADMIN is dropped by libcontainer.
    See also docker-archive/libcontainer#237, that would introduce a per-container blacklist for syscalls (including sysctl).

  15. 74 remaining items

  16. cpuguy83 commented on Aug 11, 2016

    @cpuguy83
    Member

    @nilyang It should work either way. The shell has no bearing in tweaking the kernel params.

  17. vingrad commented on Sep 20, 2016

    @vingrad

    @cpuguy83 but it's impossible to use "privileged" with docker service.
    WARNING: unsupported parameter privileged

  18. Mishi-999 commented on Feb 3, 2017

    @Mishi-999

    Hii, i am facing a critical issue while running oracle rac database in docker container solely as net.core* parameters are not set in container. I also tried with --net=host but that does not seem to help as it uses host network which limit connectivity between two rac containers and also hinders the installation.

    Is there any workaround for setting --sysctl net.core* parameters with docker run?
    Thanks in advance.

  19. thaJeztah commented on Feb 4, 2017

    @thaJeztah
    Member

    @Mishi-999 what workaround do you need? This feature is implemented in #19265, and part of docker 1.12

  20. modified the milestones: 1.12.0, 1.11.0 on Feb 4, 2017
  21. Mishi-999 commented on Feb 6, 2017

    @Mishi-999

    Thanks for your response @thaJeztah , i am using Docker-version 1.12.1 on ubuntu 4.4.0-59-generic but running --sysctl net.core.rmem_default=262144 parameter in priviledged mode shows the error -
    docker: Error response from daemon: oci runtime error: open /proc/sys/net/core/rmem_default: no such file or directory.
    Parameters are set in /etc/sysctl.conf and yet on running sysctl -a i am unable to grep "net.core.rmem_default = 262144".
    Can u please guide me in this issue.Sorry for bothering as i am new to docker.

  22. thaJeztah commented on Feb 6, 2017

    @thaJeztah
    Member

    @Mishu-999 can you open a new issue with more details and the exact steps to reproduce?

  23. rhatdan commented on Feb 6, 2017

    @rhatdan
    Contributor

    This might mean that the net/core/rmem_default is not namespaced in the kernel so it can not be set per container.

  24. thaJeztah commented on Feb 6, 2017

    @thaJeztah
    Member

    @rhatdan which means we should exclude that one from the list?

  25. justincormack commented on Feb 6, 2017

    @justincormack
    Contributor

    @thaJeztah no, thats not helpful. We could maybe improve the error message.

  26. rhatdan commented on Feb 6, 2017

    @rhatdan
    Contributor

    @thaJeztah No, since we don't know what the list is? :^( This is a case where there is a kernel sysctl which is not namespaced, but currently we believe the all NET* sysctls are namespaced, and that is all we check.

  27. Mishi-999 commented on Feb 7, 2017

    @Mishi-999

    @thaJeztah created issue #30778

  28. thaJeztah commented on Oct 24, 2017

    @thaJeztah
    Member

    @daixiang0 this issue is a feature request, and the feature was implemented last year. If you have a bug to report, please open a new issue with the information that's requested in the issue template that's shown when you open the issue. Make sure your system is fully up-to-date as CentOS uses a rolling update model (i.e. CentOS 7.3 reached end of life after 7.4 was released).

    I'm locking this issue for comments to prevent it from collecting unrelated issues (which easily go overlooked on closed issues); if you arrive here because you want to report a bug; open a new issue instead, thanks!

  29. locked and limited conversation to collaborators on Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions