Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix tutorial in readme #229

Merged
merged 3 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ youki
tags
tags.lock
tags.temp

54 changes: 36 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ For other platforms, please use [Vagrantfile](#setting-up-vagrant) that we prepa
### Debian, Ubuntu and related distributions

```sh
$ sudo apt-get install \
pkg-config \
libsystemd-dev \
libdbus-glib-1-dev
$ sudo apt-get install \
pkg-config \
libsystemd-dev \
libdbus-glib-1-dev \
build-essential
```

### Fedora, Centos, RHEL and related distributions
Expand All @@ -90,32 +91,48 @@ $ ./youki -h # you can get information about youki command

## Tutorial

Let's try to run a container that executes `sleep 5` using youki.
Maybe this tutorial is need permission as root.
Let's try to run a container that executes `sleep 30` with youki. This tutorial may need root permission.

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

chenyukang marked this conversation as resolved.
Show resolved Hide resolved
$ mkdir -p tutorial/rootfs
$ cd tutorial
$ mkdir rootfs
# use docker to export busybox into the rootfs directory
$ docker export $(docker create busybox) | tar -C rootfs -xvf -
```

Prepare a configuration file for the container that will run `sleep 5`.
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.

```sh
$ ../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": [
chenyukang marked this conversation as resolved.
Show resolved Hide resolved
"sleep", "30"
],

...
}
```

Then we can explore the lifecycle of a container:
```sh
$ curl https://gist.githubusercontent.com/utam0k/8ab419996633066eaf53ac9c66d962e7/raw/e81548f591f26ec03d85ce38b0443144573b4cf6/config.json -o config.json
$ cd ../
$ ./youki create -b tutorial tutorial_container
$ ./youki state tutorial_container # You can see the state the container is in as it is being generate.
$ ./youki start tutorial_container
$ ./youki state tutorial_container # Run it within 5 seconds to see the running container.
$ ./youki delete tutorial_container # Run it after the container is finished running.
$ 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 5`.
Change the command to be executed in `config.json` and try something other than `sleep 30`.

## Usage

Expand Down Expand Up @@ -171,8 +188,9 @@ $ git clone git@github.com:containers/youki.git
$ cd youki
$ vagrant up
$ vagrant ssh

# in virtual machine
$ cd youki # in virtual machine
$ cd youki
$ ./build.sh
```

Expand Down