mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-21 20:08:54 +00:00
runk: Support exec
sub-command
`exec` will execute a command inside a container which exists and is not frozon or stopped. *Inside* means that the new process share namespaces and cgroup with the container init process. Command can be specified by `--process` parameter to read from a file, or from other parameters such as arg, env, etc. In order to be compatible with `create`/`run` commands, I refactor libcontainer. `Container` in builder.rs is divided into `InitContainer` and `ActivatedContainer`. `InitContainer` is used for `create`/`run` command. It will load spec from given bundle path. `ActivatedContainer` is used by `exec` command, and will read the container's status file, which stores the spec and `CreateOpt` for creating the rustjail::LinuxContainer. Adapt the spec by replacing the process with given options and updating the namesapces with some paths to join the container. I also rename the `ContainerContext` as `ContainerLauncher`, which is only used to spawn process now. It uses the `LinuxContaier` in rustjail as the runner. For `create`/`run`, the `launch` method will create a new container and run the first process. For `exec`, the `launch` method will spawn a process which joins a container. Fixes #4363 Signed-off-by: Chen Yiyang <cyyzero@qq.com>
This commit is contained in:
@@ -1171,7 +1171,7 @@ fn do_exec(args: &[String]) -> ! {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
|
||||
pub fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> Result<()> {
|
||||
info!(logger, "updating namespaces");
|
||||
let linux = spec
|
||||
.linux
|
||||
|
Reference in New Issue
Block a user