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

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

Closed
vincentwoo opened this issue Apr 18, 2015 · 12 comments

Comments

@vincentwoo
Copy link
Contributor

commented Apr 18, 2015

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

@thaJeztah thaJeztah added the kind/bug label Apr 18, 2015

@cpuguy83

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2015

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.

@hqhq

This comment has been minimized.

Copy link
Contributor

commented Apr 21, 2015

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
@mischief

This comment has been minimized.

Copy link

commented Apr 21, 2015

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 ~ $
@cpuguy83

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2015

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.

@josiasmontag

This comment has been minimized.

Copy link

commented May 10, 2015

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
@cpuguy83

This comment has been minimized.

Copy link
Contributor

commented May 10, 2015

Yes, 1.6.1 only had security fixes.

@cpuguy83

This comment has been minimized.

Copy link
Contributor

commented May 10, 2015

Closing since this issue is fixed on master.

@nikolai-derzhak-distillery

This comment has been minimized.

Copy link

commented Feb 9, 2016

-1 trick does not work anymore:

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

@jorge-trujillo

This comment has been minimized.

Copy link

commented Apr 24, 2016

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

ERROR: for elasticsearch  json: cannot unmarshal number -1 into Go value of type uint64
@nikolai-derzhak-distillery

This comment has been minimized.

Copy link

commented Apr 25, 2016

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

@cpuguy83

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2016

Probably an easy fix here: https://github.com/docker/go-units/blob/master/ulimit.go#L113 to support -1 as unlimited.

@vincentwoo

This comment has been minimized.

Copy link
Contributor Author

commented Feb 14, 2017

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
Projects
None yet
8 participants
You can’t perform that action at this time.