Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

the value of ulimit can be -1 #239

Description

@ermaker

To set the ulimit unlimited, the value of ulimit can be -1. So parsing fails with this values. I am in stuck. Please see this issue ehazlett/interlock#154.

Any ideas?

Docker prints this:

            "Ulimits": [
                {
                    "Name": "memlock",
                    "Hard": -1,
                    "Soft": -1
                }
            ],

At https://github.com/samalba/dockerclient/blob/master/types.go#L516-L520

type Ulimit struct {
    Name string `json:"name"`
    Soft uint64 `json:"soft"`
    Hard uint64 `json:"hard"`
}

And for information https://github.com/docker/go-units/blob/master/ulimit.go#L9-L21

// Ulimit is a human friendly version of Rlimit.
type Ulimit struct {
    Name string
    Hard int64
    Soft int64
}

// Rlimit specifies the resource limits, such as max open files.
type Rlimit struct {
    Type int    `json:"type,omitempty"`
    Hard uint64 `json:"hard,omitempty"`
    Soft uint64 `json:"soft,omitempty"`
}

And https://github.com/docker/go-units/blob/master/ulimit.go#L106-L114

// GetRlimit returns the RLimit corresponding to Ulimit.
func (u *Ulimit) GetRlimit() (*Rlimit, error) {
    t, exists := ulimitNameMapping[u.Name]
    if !exists {
        return nil, fmt.Errorf("invalid ulimit name %s", u.Name)
    }

    return &Rlimit{Type: t, Soft: uint64(u.Soft), Hard: uint64(u.Hard)}, nil
}

Full log:

$ docker version                                                                                                                                                                          Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Tue Apr 26 23:30:23 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Tue Apr 26 23:30:23 2016
 OS/Arch:      linux/amd64
$ docker-compose version                                                                                                                                                                  docker-compose version 1.7.0, build 0d7bf73
docker-py version: 1.8.0
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
$ uname -a                                                                                                                                                                                Linux dev 3.13.0-85-generic #129-Ubuntu SMP Thu Mar 17 20:50:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ cat docker-compose.yml                                                                                                                                                                  version: '2'
services:
  interlock:
    image: ehazlett/interlock:1.1.1
    container_name: interlock
    command: -D run
    ports:
      - 8080
    environment:
      INTERLOCK_CONFIG: |
        ListenAddr = ":8080"
        DockerURL = "unix:///var/run/docker.sock"
        TLSCACert = "/etc/docker/ca.pem"
        TLSCert = "/etc/docker/server.pem"
        TLSKey = "/etc/docker/server-key.pem"
        [[Extensions]]
        Name = "nginx"
        ConfigPath = "/etc/nginx/nginx.conf"
        PidPath = "/var/run/nginx.pid"
        TemplatePath = ""
        MaxConn = 1024
    volumes:
      - /etc/docker:/etc/docker:ro
      - /var/run/docker.sock:/var/run/docker.sock
    network_mode: bridge
    restart: always
  nginx:
    image: nginx
    container_name: nginx
    entrypoint: nginx
    command: -g "daemon off;" -c /etc/nginx/nginx.conf
    ports:
      - 80:80
    labels:
      - "interlock.ext.name=nginx"
    network_mode: bridge
    restart: always
  app:
    image: ehazlett/docker-demo
    container_name: app
    hostname: test.local
    ulimits:
      memlock: -1
    ports:
      - 8080
$ docker inspect app                                                                                                                                                                      [
    {
        "Id": "284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b",
        "Created": "2016-05-17T13:51:09.906017029Z",
        "Path": "/bin/docker-demo",
        "Args": [
            "-listen=:8080"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 9280,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2016-05-17T13:51:10.060165813Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:69b663051ba5740f495dc86f6eca34bc98f6704672298356bb200aea036e94bd",
        "ResolvConfPath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/hostname",
        "HostsPath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/hosts",
        "LogPath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b-json.log",
        "Name": "/app",
        "RestartCount": 0,
        "Driver": "aufs",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "test2_default",
            "PortBindings": {
                "8080/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": ""
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "StorageOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": [
                {
                    "Name": "memlock",
                    "Hard": -1,
                    "Soft": -1
                }
            ],
            "CpuCount": 0,
            "CpuPercent": 0,
            "BlkioIOps": 0,
            "BlkioBps": 0,
            "SandboxSize": 0
        },
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        },
        "Mounts": [],
        "Config": {
            "Hostname": "test",
            "Domainname": "local",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "-listen=:8080"
            ],
            "Image": "ehazlett/docker-demo",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/bin/docker-demo"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "a74c0dbc9be4e2b268244966f4d99e3fe0b47660424edcde7f84f2990cce0791",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "test2",
                "com.docker.compose.service": "app",
                "com.docker.compose.version": "1.7.0"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "2e81ad8e6a44ee396e618d5dbb0b3a27f352e707b316cfd593a14331c955bf62",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8080/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32809"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/2e81ad8e6a44",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "test2_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "app",
                        "284032cb1fff"
                    ],
                    "NetworkID": "5cc8abf32d129693cd4a7c846a423a32f0c8b93c52ea6c543f15ee6d41cd2e8b",
                    "EndpointID": "06cb88a36cdf04949ff6e287821ecc34e854810f2414d5e41fe902f885dcb61d",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:02"
                }
            }
        }
    }
]

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions