fix(code-runner): 去掉 nproc ulimit,修复容器启动 EAGAIN
容器启动时报 'exec /bin/sh: resource temporarily unavailable',根因是
HostConfig 里的 ulimit nproc=64 与 non-root user(1000:1000) 组合:
RLIMIT_NPROC 按 UID 计数且在容器初始 exec 阶段就生效,与容器内实际进程数无关,
导致 sh 都起不来。pids_limit=64 已在 cgroup 层兜底进程数限制,nproc 是冗余且
有害的双重约束。
复现:docker run --ulimit nproc=64 --user 1000:1000 → exec 失败
去掉 nproc(保留 nofile + pids_limit + 其他沙箱约束)→ python/node 正常运行
cargo test infra::docker 全过。
This commit is contained in:
parent
2cfc64b319
commit
a7a97fc299
@ -31,9 +31,12 @@ pub fn build_host_config(limits: &ResourceLimits) -> HostConfig {
|
||||
readonly_rootfs: Some(true),
|
||||
tmpfs: Some(tmpfs),
|
||||
pids_limit: Some(64),
|
||||
// 只保留 nofile(fd 数上限,语义正常)。
|
||||
// 不设 nproc:RLIMIT_NPROC 在 setrlimit 时按 UID 计数,配合 non-root 用户会让
|
||||
// 容器初始 exec /bin/sh 直接 EAGAIN("exec: resource temporarily unavailable"),
|
||||
// 与容器内实际进程数无关。pids_limit 已在 cgroup 层兜底,nproc 是冗余且有害的双重约束。
|
||||
ulimits: Some(vec![
|
||||
ResourcesUlimits { name: Some("nofile".to_string()), soft: Some(64), hard: Some(64) },
|
||||
ResourcesUlimits { name: Some("nproc".to_string()), soft: Some(64), hard: Some(64) },
|
||||
]),
|
||||
cap_drop: Some(vec!["ALL".to_string()]),
|
||||
security_opt: Some(vec!["no-new-privileges".to_string()]),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user