fix(docker): 用 tmpfs mode=1777 替换 uid/gid 选项以兼容 Podman

This commit is contained in:
xfy 2026-07-14 16:42:04 +08:00
parent af3cd4b525
commit e18d2bfb2c

View File

@ -20,7 +20,11 @@ pub static DOCKER_CLIENT: LazyLock<Docker> = LazyLock::new(|| {
pub fn build_host_config(limits: &ResourceLimits) -> HostConfig { pub fn build_host_config(limits: &ResourceLimits) -> HostConfig {
let mut tmpfs = HashMap::new(); let mut tmpfs = HashMap::new();
tmpfs.insert("/code".to_string(), "size=16m,uid=1000,gid=1000".to_string()); // /code 用 mode=1777sticky + all-rwx让容器内 1000:1000 用户可写。
// 不用 `uid=1000,gid=1000`:那是 Docker 的 tmpfs 扩展选项Podman 报
// `unknown mount option "uid=1000"`。mode=1777 是 POSIX 标准 tmpfs 选项,
// Docker 与 Podman 都支持,语义等价(任意 UID 可写 /code
tmpfs.insert("/code".to_string(), "size=16m,mode=1777".to_string());
// /tmp 必须 exec编译型语言go/rust把编译产物落在 /tmp 后再 exec // /tmp 必须 exec编译型语言go/rust把编译产物落在 /tmp 后再 exec
// Docker tmpfs 默认 noexec 会让执行二进制时报 EACCESpermission denied // Docker tmpfs 默认 noexec 会让执行二进制时报 EACCESpermission denied
// 解释型语言python/node执行根文件系统的解释器不受影响。 // 解释型语言python/node执行根文件系统的解释器不受影响。