https://github.com/apachecn-archive/youki

https://github.com/apachecn-archive/youki

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: apachecn-archive
  • License: apache-2.0
  • Language: Rust
  • Default Branch: main
  • Size: 9.48 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme License Code of conduct Security

README.md

youki: A container runtime in Rust

Discord GitHub contributors Github CI codecov

youki is an implementation of the OCI runtime-spec in Rust, similar to runc.

About the name

youki is pronounced as /joʊki/ or yoh-key. youki is named after the Japanese word 'youki', which means 'a container'. In Japanese language, youki also means 'cheerful', 'merry', or 'hilarious'.

Motivation

Here is why we are writing a new container runtime in Rust.

  • Rust is one of the best languages to implement the oci-runtime spec. Many very nice container tools are currently written in Go. However, the container runtime requires the use of system calls, which requires a bit of special handling when implemented in Go. This is too tricky (e.g. namespaces(7), fork(2)); with Rust, it's not that tricky. And, unlike in C, Rust provides the benefit of memory safety. While Rust is not yet a major player in the container field, it has the potential to contribute a lot: something this project attempts to exemplify.
  • youki has the potential to be faster and use less memory than runc, and therefore work in environments with tight memory usage requirements. I don't have any benchmarks, as it is not yet fully operational, but I expect that Rust's semantics will lead to higher performance, despite the fact that current implementations such as crun, a container runtime implemented in C, already have quite high performance. For example, it may be possible to experiment with algorithmic improvements with asynchronous processing using async/await in some parts.
  • The development of railcar has been suspended. This project was very nice but is no longer being developed. This project is inspired by it.
  • I have fun implementing this. In fact, this may be the most important.

Related project

Status of youki

youki is not at the practical stage yet. However, it is getting closer to practical use, running with docker and passing all the default tests provided by opencontainers/runtime-tools. youki demo

| Feature | Description | State | | :------------: | :---------------------------------------------: | :-------------------------------------------------------------------------------------------------: | | Docker | Running via Docker | ✅ | | Podman | Running via Podman | It works, but cgroups isn't supported. WIP on #24 | | pivot_root | Change the root directory | ✅ | | Mounts | Mount files and directories to container | ✅ | | Namespaces | Isolation of various resources | ✅ | | Capabilities | Limiting root privileges | ✅ | | Cgroups v1 | Resource limitations, etc | ✅ | | Cgroups v2 | Improved version of v1 | Support is complete except for devices. WIP on #78 | | Seccomp | Filtering system calls | ✅ | | Hooks | Add custom processing during container creation | ✅ | | Rootless | Running a container without root privileges | It works, but cgroups isn't supported. WIP on #77 | | OCI Compliance | Compliance with OCI Runtime Spec | ✅ 50 out of 50 test cases passing |

Design and implementation of youki

sequence diagram of youki

More details are in the works #14

Getting Started

Local build is only supported on Linux. For other platforms, please use Vagrantfile that we prepared.

Requires

Dependencies

Debian, Ubuntu and related distributions

console $ sudo apt-get install \ pkg-config \ libsystemd-dev \ libdbus-glib-1-dev \ build-essential \ libelf-dev \ libseccomp-dev

Fedora, Centos, RHEL and related distributions

console $ sudo dnf install \ pkg-config \ systemd-devel \ dbus-devel \ elfutils-libelf-devel \ libseccomp-devel

Build

console $ git clone git@github.com:containers/youki.git $ cd youki $ ./build.sh $ ./youki -h # you can get information about youki command

Tutorial

Create and run a container

Let's try to run a container that executes sleep 30 with youki. This tutorial may need root permission.

```console $ git clone git@github.com:containers/youki.git $ cd youki $ ./build.sh

$ mkdir -p tutorial/rootfs $ cd tutorial

use docker to export busybox into the rootfs directory

$ docker export $(docker create busybox) | tar -C rootfs -xvf - ```

Then, we need to prepare a configuration file. This file contains metadata and specs for a container, such as the process to run, environment variables to inject, sandboxing features to use, etc.

cconsole $ ../youki spec # will generate a spec file named config.json

We can edit the config.json to add customized behaviors for container. Here, we modify the process field to run sleep 30.

```json "process": { ... "args": [ "sleep", "30" ],

... } ```

Then we can explore the lifecycle of a container: console $ cd .. # go back to the repository root $ sudo ./youki create -b tutorial tutorial_container # create a container with name `tutorial_container` $ sudo ./youki state tutorial_container # you can see the state the container is `created` $ sudo ./youki start tutorial_container # start the container $ sudo ./youki list # will show the list of containers, the container is `running` $ sudo ./youki delete tutorial_container # delete the container

Change the command to be executed in config.json and try something other than sleep 30.

Rootless container

youki provides the ability to run containers as non-root user(rootless mode). To run a container in rootless mode, we need to add some extra options in config.json, other steps are same with above:

```console $ mkdir -p tutorial/rootfs $ cd tutorial

use docker to export busybox into the rootfs directory

$ docker export $(docker create busybox) | tar -C rootfs -xvf -

$ ../youki spec --rootless # will generate a spec file named config.json with rootless mode

Modify the args field as you like

$ ../youki run rootless-container # will create and run a container with rootless mode ```

Usage

Start the docker daemon.

console $ dockerd --experimental --add-runtime="youki=$(pwd)/target/x86_64-unknown-linux-gnu/debug/youki"

If you get an error like the below, that means your normal Docker daemon is running, and it needs to be stopped. Do that with your init system (i.e., with systemd, run systemctl stop docker, as root if necessary).

failed to start daemon: pid file found, ensure docker is not running or delete /var/run/docker.pid

Now repeat the command, which should start the docker daemon.

You can use youki in a different terminal to start the container.

console $ docker run -it --rm --runtime youki busybox

Afterwards, you can close the docker daemon process in other the other terminal. To restart normal docker daemon (if you had stopped it before), run:

console $ systemctl start docker # might need root permission

Integration Tests

Go and node-tap are required to run integration tests. See the opencontainers/runtime-tools README for details.

```console $ git submodule update --init --recursive $ ./integration_test.sh

run specific test_cases with pattern

$ ./integrationtest.sh linux* ```

Setting up Vagrant

You can try youki on platforms other than Linux by using the Vagrantfile we have prepared. We have prepared two environments for vagrant, namely rootless mode and rootful mode

```console $ git clone git@github.com:containers/youki.git $ cd youki

If you want to develop in rootless mode, and this is the default mode

$ vagrant up $ vagrant ssh

or if you want to develop in rootful mode

$ VAGRANTVAGRANTFILE=Vagrantfile.root vagrant up $ VAGRANTVAGRANTFILE=Vagrantfile.root vagrant ssh

in virtual machine

$ cd youki $ ./build.sh ```

Community

We also have an active Discord if you'd like to come and chat with us.

Contribution

This project welcomes your PR and issues. For example, refactoring, adding features, correcting English, etc. If you need any help, you can contact me on Twitter.

Thanks to all the people who already contributed!

Owner

  • Name: ApacheCN 归档
  • Login: apachecn-archive
  • Kind: organization
  • Email: wizard.z@qq.com

防止重要项目丢失而设立的归档

GitHub Events

Total
Last Year

Dependencies

.github/workflows/integration_tests_validation.yaml actions
  • Swatinem/rust-cache v1 composite
  • actions-rs/toolchain v1 composite
  • actions/checkout v2 composite
  • dorny/paths-filter v2 composite
.github/workflows/main.yml actions
  • Swatinem/rust-cache v1 composite
  • actions-rs/toolchain v1 composite
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-go v2 composite
  • codecov/codecov-action v2 composite
  • dorny/paths-filter v2 composite
Cargo.lock cargo
  • 141 dependencies
Cargo.toml cargo
crates/integration_test/Cargo.lock cargo
  • adler 1.0.2
  • anyhow 1.0.44
  • autocfg 1.0.1
  • bitflags 1.3.2
  • byteorder 1.4.3
  • cfg-if 1.0.0
  • chrono 0.4.19
  • clap 3.0.0-beta.2
  • clap_derive 3.0.0-beta.2
  • crc32fast 1.2.1
  • crossbeam 0.8.1
  • crossbeam-channel 0.5.1
  • crossbeam-deque 0.8.1
  • crossbeam-epoch 0.9.5
  • crossbeam-queue 0.3.2
  • crossbeam-utils 0.8.5
  • darling 0.12.4
  • darling_core 0.12.4
  • darling_macro 0.12.4
  • derive_builder 0.10.2
  • derive_builder_core 0.10.2
  • derive_builder_macro 0.10.2
  • either 1.6.1
  • filetime 0.2.15
  • flate2 1.0.22
  • fnv 1.0.7
  • getrandom 0.2.3
  • getset 0.1.1
  • hashbrown 0.11.2
  • heck 0.3.3
  • hex 0.4.3
  • ident_case 1.0.1
  • indexmap 1.7.0
  • itoa 0.4.8
  • lazy_static 1.4.0
  • libc 0.2.104
  • memoffset 0.6.4
  • miniz_oxide 0.4.4
  • num-integer 0.1.44
  • num-traits 0.2.14
  • once_cell 1.8.0
  • os_str_bytes 2.4.0
  • ppv-lite86 0.2.14
  • proc-macro-error 1.0.4
  • proc-macro-error-attr 1.0.4
  • proc-macro2 1.0.30
  • procfs 0.11.0
  • quote 1.0.10
  • rand 0.8.4
  • rand_chacha 0.3.1
  • rand_core 0.6.3
  • rand_hc 0.3.1
  • redox_syscall 0.2.10
  • ryu 1.0.5
  • scopeguard 1.1.0
  • serde 1.0.130
  • serde_derive 1.0.130
  • serde_json 1.0.68
  • strsim 0.10.0
  • syn 1.0.80
  • tar 0.4.37
  • textwrap 0.12.1
  • thiserror 1.0.30
  • thiserror-impl 1.0.30
  • time 0.1.43
  • unicode-segmentation 1.8.0
  • unicode-width 0.1.9
  • unicode-xid 0.2.2
  • uuid 0.8.2
  • vec_map 0.8.2
  • version_check 0.9.3
  • wasi 0.10.2+wasi-snapshot-preview1
  • which 4.2.2
  • winapi 0.3.9
  • winapi-i686-pc-windows-gnu 0.4.0
  • winapi-x86_64-pc-windows-gnu 0.4.0
  • xattr 0.2.2
crates/integration_test/Cargo.toml cargo
crates/libcgroups/Cargo.toml cargo
  • clap 3.0.0-beta.2 development
  • env_logger 0.9 development
  • quickcheck 1 development
  • serde 1.0 development
  • serde_json 1.0 development
  • anyhow 1.0
  • dbus 0.9.2
  • errno 0.2.7
  • libbpf-sys 0.4.0-2
  • libc 0.2.84
  • log 0.4
  • nix 0.22.0
  • procfs 0.11.0
  • rbpf 0.1.0
  • serde 1.0
  • systemd 0.8
crates/libcontainer/Cargo.toml cargo
  • quickcheck 1 development
  • serial_test 0.5.1 development
  • anyhow 1.0
  • chrono 0.4
  • crossbeam-channel 0.5
  • dbus 0.9.2
  • fastrand 1.4.1
  • futures 0.3
  • libc 0.2.84
  • libcgroups 0.1.0
  • libseccomp 0.1.0
  • log 0.4
  • mio 0.7.13
  • nix 0.22.0
  • path-clean 0.1.0
  • prctl 1.0.0
  • procfs 0.11.0
  • serde 1.0
  • serde_json 1.0
  • systemd 0.8
crates/libseccomp/Cargo.toml cargo
crates/test_framework/Cargo.toml cargo
crates/youki/Cargo.toml cargo
  • serial_test 0.5.1 development
  • anyhow 1.0
  • chrono 0.4
  • clap 3.0.0-beta.2
  • log 0.4
  • nix 0.22.0
  • once_cell 1.6.0
  • pentacle 1.0.0
  • procfs 0.11.0
  • serde 1.0
  • serde_json 1.0
  • tabwriter 1