Skip to content

docker --ulimit does not support unlimited or large numbers #12515

Closed

Description

@vincentwoo

While trying to get my containers to generate core file dumps, I ran into an issue setting the ulimit high enough. Would love an explanation, as I have no idea why upping to 1000000 doesn't seem to have an effect!

$ docker run --ulimit core=999999 -t ubuntu:12.04 bash -c "ulimit -c"
976
$ docker run --ulimit core=1000000 -t ubuntu:12.04 bash -c "ulimit -c"
0
$ docker run --ulimit core=unlimited -t ubuntu:12.04 bash -c "ulimit -c"
invalid value "core=unlimited" for flag --ulimit: strconv.ParseInt: parsing "unlimited": invalid syntax
See 'docker run --help'.

running on

$ docker --version
Docker version 1.6.0, build 4749651
$ docker info
Containers: 1
Images: 555
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 557
 Dirperm1 Supported: false
Execution Driver: native-0.2
Kernel Version: 3.11.0-12-generic
Operating System: Ubuntu 13.10
CPUs: 2
Total Memory: 3.767 GiB
Name: ubuntu
ID: 6LST:RRCU:BKCS:Z73Y:HOMA:UUY7:RHNL:YRDY:52H6:IGID:SL3G:57BR
Registry: [https://index.docker.io/v1/]

Activity

  1. added
    kind/bug
    on Apr 18, 2015
  2. cpuguy83 commented on Apr 19, 2015

    @cpuguy83
    Member

    Quite strange.
    I can confirm I'm seeing the same issue.
    However, running the same basic code that Docker/libcontainer are running I cannot repro:

    import (
        "log"
        "os"
        "os/exec"
        "syscall"
    
        "github.com/docker/docker/pkg/ulimit"
    )
    
    func main() {
        u, err := ulimit.Parse(os.Args[1])
        if err != nil {
            log.Fatal(err)
        }
    
        r, err := u.GetRlimit()
        if err != nil {
            log.Fatal(err)
        }
    
        l := &syscall.Rlimit{Max: r.Hard, Cur: r.Soft}
        if err := syscall.Setrlimit(r.Type, l); err != nil {
            log.Fatal(err)
        }
        cmd := exec.Command("/bin/sh", "-c", "ulimit -c")
        cmd.Stdout = os.Stdout
        cmd.Stderr = os.Stderr
    
        cmd.Run()
    }

    unlimited is purposefully not support since it's not a real value, it's just a constant set to a really high number.

  3. hqhq commented on Apr 21, 2015

    @hqhq
    Contributor

    I can't reproduce, the latest master code works fine for me:

    $ docker run --ulimit core=999999 -t --rm ubuntu:14.04 bash -c "ulimit -c"
    976
    $ docker run --ulimit core=1000000 -t --rm ubuntu:14.04 bash -c "ulimit -c"
    976
    $ docker run --ulimit core=10000000 -t --rm ubuntu:14.04 bash -c "ulimit -c"
    9765
    
  4. mischief commented on Apr 21, 2015

    @mischief

    rather amusing behavior:

    core@coreos_production_qemu-653-0-0-2 ~ $ docker run --ulimit nofile=1000000 -t --rm ubuntu:14.04 bash -c "ulimit -n"
    FATA[0000] Error response from daemon: Cannot start container cbeb24aee366292fe9a94b5b481d8fa0c7681eefb546ef982ebaa43b036058a1: [8] System error: open /var/lib/docker/overlay/cbeb24aee366292fe9a94b5b481d8fa0c7681eefb546ef982ebaa43b036058a1/merged/dev/console: too many open files 
    core@coreos_production_qemu-653-0-0-2 ~ $ docker info
    Containers: 12
    Images: 8
    Storage Driver: overlay
     Backing Filesystem: extfs
    Execution Driver: native-0.2
    Kernel Version: 4.0.0
    Operating System: CoreOS 653.0.0+2015-04-20-1835
    CPUs: 4
    Total Memory: 997.5 MiB
    Name: coreos_production_qemu-653-0-0-2
    ID: YURS:H7BQ:2VVN:DH22:3NUJ:S6TD:P2QT:7OWF:EPEQ:KO2K:ZD2B:CJQ2
    core@coreos_production_qemu-653-0-0-2 ~ $ docker version
    Client version: 1.6.0
    Client API version: 1.18
    Go version (client): go1.3.3
    Git commit (client): 4749651-dirty
    OS/Arch (client): linux/amd64
    Server version: 1.6.0
    Server API version: 1.18
    Go version (server): go1.3.3
    Git commit (server): 4749651-dirty
    OS/Arch (server): linux/amd64
    core@coreos_production_qemu-653-0-0-2 ~ $
    
  5. cpuguy83 commented on Apr 22, 2015

    @cpuguy83
    Member

    Yes, this is really weird... I wonder what commit fixed this... cc @LK4D4 @crosbymichael
    If there is a 1.6.1, surely the commit that fixes this needs to be in it.

  6. josiasmontag commented on May 10, 2015

    @josiasmontag

    Issue is not solved with 1.6.1.
    Workaround in the meantime: Use magic -1.

    $docker run --ulimit core=-1 -t --rm busybox sh -c "ulimit -c"
    unlimited
    
  7. cpuguy83 commented on May 10, 2015

    @cpuguy83
    Member

    Yes, 1.6.1 only had security fixes.

  8. cpuguy83 commented on May 10, 2015

    @cpuguy83
    Member

    Closing since this issue is fixed on master.

  9. nikolai-derzhak-distillery commented on Feb 9, 2016

    @nikolai-derzhak-distillery

    -1 trick does not work anymore:

    docker: Error response from daemon: json: cannot unmarshal number -1 into Go value of type uint64.

  10. jorge-trujillo commented on Apr 24, 2016

    @jorge-trujillo

    Any update on this? docker-compose still returns this error:

    ERROR: for elasticsearch  json: cannot unmarshal number -1 into Go value of type uint64
    
  11. nikolai-derzhak-distillery commented on Apr 25, 2016

    @nikolai-derzhak-distillery

    I use next constant as workaround:

    --ulimit memlock=9223372036854775807
    

    Comment from my code:

    ulimit -1 throws error as it uint64 now in docker code

    so we use 2^63-1 number as equal value

  12. cpuguy83 commented on Apr 25, 2016

    @cpuguy83
    Member
  13. vincentwoo commented on Feb 14, 2017

    @vincentwoo
    ContributorAuthor

    For those on this issue, setting -1 does appear to work as of Docker 1.13.

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/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions