Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Units for `--ulimit memlock` is counter intuitive

未关闭
#5,799 1 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
docker, linux

调研方向

首先复现文档中的 docker run --ulimit memlock=4096 ubuntu 命令,并将其结果与 Linux 的 ulimit -a 输出进行比较。跟踪负责解析 --ulimit 的 CLI 入口点,并查阅相关的 Docker 文档;如果单元行为已修正或得到明确记录,并且在适用时覆盖基于大小的限制,则视为完成。

由索引模型根据 Issue 内容生成。

描述

kind/bug status/0-triage
Description

From Linux, the units for memlock are in kb. However docker run --ulimit memlock appears to use bytes. Since I wasn't able to find docker documentation to indicate it uses bytes instead of kb, using this setting was counter intuitive.

Notes:

I have not tried other --ulimit settings that are based on size, but it appears at least a few others use kb in Linux and I'm guessing those may also be affected by this.

Reproduce

Using 4096 I expect to get 4096k but in the container, limits -a shows 4k for "max locked memory"

docker run --rm -it --ulimit memlock=4096 ubuntu
root@d1290e92e5f8:/# ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 29730
max locked memory           (kbytes, -l) 4
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1073741816
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) unlimited
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

I attempted adding a unit to the call like --ulimit memlock=4096kb or --ulimit memlock=4096k but that immediately fails:

docker run --rm -it --ulimit memlock=4096kb ubuntu
invalid argument "memlock=4096kb" for "--ulimit" flag: strconv.ParseInt: parsing "4096kb": invalid syntax
See 'docker run --help'.
Expected behavior

One of:

  • Use kb as the units instead of bytes
  • Support (or require) specifying units so users can be explicit
  • Document that --ulimit uses bytes instead of kb
docker version
Client: Docker Engine - Community
 Version:           27.1.1
 API version:       1.46
 Go version:        go1.21.12
 Git commit:        6312585
 Built:             Fri Jul 26 06:15:46 2024
 OS/Arch:           linux/s390x
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.1.1
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.12
  Git commit:       cc13f95
  Built:            Fri Jul 26 06:45:34 2024
  OS/Arch:          linux/s390x
  Experimental:     false
 containerd:
  Version:          1.7.19
  GitCommit:        2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41
 runc:
  Version:          1.7.19
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker info
Client: Docker Engine - Community
 Version:    27.1.1
 Context:    default
 Debug Mode: false

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 5
 Server Version: 27.1.1
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Authorization: <*******>
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  userns
  cgroupns
 Kernel Version: 5.14.0-427.40.1.el9.zfpc10.8.s390x
 Operating System: Linux
 OSType: linux
 Architecture: s390x
 CPUs: 2
 Total Memory: 7.314GiB
 Name: <*******>
 ID: a86f1633-c963-41d2-963a-76590c1ab455
 Docker Root Dir: /media/data/docker/24000.109
 Debug Mode: false
 Username: <********>
 Labels:
  platform=zOS
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
Additional Info

Limits.conf doc pages showing memlock as kb

主要语言
Go
星标
6.1k
派生
2.2k
平均合并
1 天 10 小时
30 天内合并 PR
47

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/cli 的其他 Issue

查看 docker/cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。