Skip to content

poststart run before user-specified process? #1260

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ningmingxiao opened this issue Jul 15, 2024 · 1 comment
Closed

poststart run before user-specified process? #1260

ningmingxiao opened this issue Jul 15, 2024 · 1 comment

Comments

@ningmingxiao
Copy link

ningmingxiao commented Jul 15, 2024

config.json

{
    "ociVersion": "1.0.2-dev",
    "process": {
            "terminal": false,
            "user": {
                    "uid": 0,
                    "gid": 0
            },
            "args": [
                    "sh"
            ],
            "env": [
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "TERM=xterm"
            ],
            "cwd": "/",
            "capabilities": {
                    "bounding": [
                            "CAP_AUDIT_WRITE",
                            "CAP_KILL",
                            "CAP_NET_BIND_SERVICE"
                    ],
                    "effective": [
                            "CAP_AUDIT_WRITE",
                            "CAP_KILL",
                            "CAP_NET_BIND_SERVICE"
                    ],
                    "permitted": [
                            "CAP_AUDIT_WRITE",
                            "CAP_KILL",
                            "CAP_NET_BIND_SERVICE"
                    ],
                    "ambient": [
                            "CAP_AUDIT_WRITE",
                            "CAP_KILL",
                            "CAP_NET_BIND_SERVICE"
                    ]
            },
            "rlimits": [
                    {
                            "type": "RLIMIT_NOFILE",
                            "hard": 1024,
                            "soft": 1024
                    }
            ],
            "noNewPrivileges": true
    },
    "root": {
            "path": "rootfs",
            "readonly": false
    },
    "hostname": "runc",
    "mounts": [
            {
                    "destination": "/proc",
                    "type": "proc",
                    "source": "proc"
            },
            {
                    "destination": "/dev",
                    "type": "tmpfs",
                    "source": "tmpfs",
                    "options": [
                            "nosuid",
                            "strictatime",
                            "mode=755",
                            "size=65536k"
                    ]
            },
            {
                    "destination": "/dev/pts",
                    "type": "devpts",
                    "source": "devpts",
                    "options": [
                            "nosuid",
                            "noexec",
                            "newinstance",
                            "ptmxmode=0666",
                            "mode=0620"
                    ]
            },
            {
                    "destination": "/dev/shm",
                    "type": "tmpfs",
                    "source": "shm",
                    "options": [
                            "nosuid",
                            "noexec",
                            "nodev",
                            "mode=1777",
                            "size=65536k"
                    ]
            },
            {
                    "destination": "/dev/mqueue",
                    "type": "mqueue",
                    "source": "mqueue",
                    "options": [
                            "nosuid",
                            "noexec",
                            "nodev"
                    ]
            },
            {
                    "destination": "/sys",
                    "type": "sysfs",
                    "source": "sysfs",
                    "options": [
                            "nosuid",
                            "noexec",
                            "nodev",
                            "ro"
                    ]
            },
            {
                    "destination": "/sys/fs/cgroup",
                    "type": "cgroup",
                    "source": "cgroup",
                    "options": [
                            "nosuid",
                            "noexec",
                            "nodev",
                            "relatime",
                            "ro"
                    ]
            }
    ],
    "hooks": {
            "Poststart": [
                {
                    "path": "/usr/bin/sleep",
                    "args":  ["/usr/bin/sleep","10"]
                }
            ]
    },
    "linux": {
            "resources": {
                    "devices": [
                            {
                                    "allow": false,
                                    "access": "rwm"
                            }
                    ]
            },
            "uidMappings": [
                    {
                            "containerID": 0,
                            "hostID": 1000,
                            "size": 1
                    }
            ],
            "gidMappings": [
                    {
                            "containerID": 0,
                            "hostID": 1000,
                            "size": 1
                    }
            ],
            "namespaces": [
                    {
                            "type": "pid"
                    },
                    {
                            "type": "network"
                    },
                    {
                            "type": "ipc"
                    },
                    {
                            "type": "uts"
                    },
                    {
                            "type": "mount"
                    }
            ],
            "maskedPaths": [
                    "/proc/acpi",
                    "/proc/asound",
                    "/proc/kcore",
                    "/proc/keys",
                    "/proc/latency_stats",
                    "/proc/timer_list",
                    "/proc/timer_stats",
                    "/proc/sched_debug",
                    "/sys/firmware",
                    "/proc/scsi"
            ],
            "readonlyPaths": [
                    "/proc/bus",
                    "/proc/fs",
                    "/proc/irq",
                    "/proc/sys",
                    "/proc/sysrq-trigger"
            ]
    }
}

I just set

            "Poststart": [
                {
                    "path": "/usr/bin/sleep",
                    "args":  ["/usr/bin/sleep","10"]
                }
[root@localhost mycontainer]# time runc create test0001

real    0m10.199s
user    0m0.010s
sys     0m0.035s

that means user-specified process doesn't run. (user-specified process will run in runc start stage). @utam0k
does user-specified process means following code ?

            "args": [
                    "sh"
            ],

@kolyshkin @utam0k

@cyphar
Copy link
Member

cyphar commented Jul 15, 2024

I'm going to close this and re-open #1259. For reference, if you need to open a new issue please link back to the old one so folks can follow the conversation. This issue description is a reply with no context to a comment in an unreferenced issue so it's a bit hard to figure out what you're trying to say.

@cyphar cyphar closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants