commit
582c2712cc
3 changed files with 200 additions and 288 deletions
109
README.md
109
README.md
|
@ -86,25 +86,20 @@ USAGE:
|
||||||
containerd [global options] command [command options] [arguments...]
|
containerd [global options] command [command options] [arguments...]
|
||||||
|
|
||||||
VERSION:
|
VERSION:
|
||||||
0.0.4
|
0.1.0 commit: 54c213e8a719d734001beb2cb8f130c84cc3bd20
|
||||||
|
|
||||||
AUTHOR(S):
|
|
||||||
@crosbymichael <crosbymichael@gmail.com>
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
help, h Shows a list of commands or help for one command
|
help, h Shows a list of commands or help for one command
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
--id "deathstar" unique containerd id to identify the instance
|
--debug enable debug output in the logs
|
||||||
--debug enable debug output in the logs
|
--state-dir "/run/containerd" runtime state directory
|
||||||
--state-dir "/run/containerd" runtime state directory
|
--metrics-interval "5m0s" interval for flushing metrics to the store
|
||||||
-c, --concurrency "10" set the concurrency level for tasks
|
--listen, -l "/run/containerd/containerd.sock" Address on which GRPC API will listen
|
||||||
--metrics-interval "1m0s" interval for flushing metrics to the store
|
--runtime, -r "runc" name of the OCI compliant runtime to use when executing containers
|
||||||
--listen, -l "/run/containerd/containerd.sock" Address on which GRPC API will listen
|
--graphite-address Address of graphite server
|
||||||
--oom-notify enable oom notifications for containers
|
--help, -h show help
|
||||||
--graphite-address Address of graphite server
|
--version, -v print the version
|
||||||
--help, -h show help
|
|
||||||
--version, -v print the version
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Roadmap
|
# Roadmap
|
||||||
|
@ -127,37 +122,58 @@ There is a default cli named `ctr` based on the GRPC api.
|
||||||
This cli will allow you to create and manage containers run with containerd.
|
This cli will allow you to create and manage containers run with containerd.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
$ ctr -h
|
||||||
NAME:
|
NAME:
|
||||||
ctr - High performance container daemon controller
|
ctr - High performance container daemon cli
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
ctr [global options] command [command options] [arguments...]
|
ctr [global options] command [command options] [arguments...]
|
||||||
|
|
||||||
VERSION:
|
VERSION:
|
||||||
0.0.4
|
0.1.0 commit: 54c213e8a719d734001beb2cb8f130c84cc3bd20
|
||||||
|
|
||||||
AUTHOR(S):
|
|
||||||
@crosbymichael <crosbymichael@gmail.com>
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
checkpoints list all checkpoints
|
checkpoints list all checkpoints
|
||||||
containers interact with running containers
|
containers interact with running containers
|
||||||
events receive events from the containerd daemon
|
events receive events from the containerd daemon
|
||||||
help, h Shows a list of commands or help for one command
|
state get a raw dump of the containerd state
|
||||||
|
help, h Shows a list of commands or help for one command
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
--debug enable debug output in the logs
|
--debug enable debug output in the logs
|
||||||
--address "/run/containerd/containerd.sock" address of GRPC API
|
--address "/run/containerd/containerd.sock" address of GRPC API
|
||||||
--help, -h show help
|
--help, -h show help
|
||||||
--version, -v print the version
|
--version, -v print the version
|
||||||
|
```
|
||||||
|
|
||||||
|
### Starting a container
|
||||||
|
|
||||||
```
|
```
|
||||||
|
$ ctr containers start -h
|
||||||
|
NAME:
|
||||||
|
ctr containers start - start a container
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
ctr containers start [command options] [arguments...]
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
--checkpoint, -c checkpoint to start the container from
|
||||||
|
--attach, -a connect to the stdio of the container
|
||||||
|
--label, -l [--label option --label option] set labels for the container
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo ctr containers start redis /containers/redis
|
||||||
|
```
|
||||||
|
Note: `/containers/redis` is the path of bundle you have to prepare before
|
||||||
|
running a contianer, see [bundle](docs/bundle.md) to get more information.
|
||||||
|
|
||||||
|
|
||||||
### Listing containers
|
### Listing containers
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ sudo ctr containers
|
$ sudo ctr containers
|
||||||
ID PATH STATUS PID1
|
ID PATH STATUS PROCESSES
|
||||||
1 /containers/redis running 14063
|
1 /containers/redis running 14063
|
||||||
19 /containers/redis running 14100
|
19 /containers/redis running 14100
|
||||||
14 /containers/redis running 14117
|
14 /containers/redis running 14117
|
||||||
|
@ -180,38 +196,18 @@ ID PATH STATUS PID1
|
||||||
0 /containers/redis running 14006
|
0 /containers/redis running 14006
|
||||||
```
|
```
|
||||||
|
|
||||||
### Starting a container
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ctr containers start -h
|
|
||||||
NAME:
|
|
||||||
start - start a container
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
command start [command options] [arguments...]
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
--checkpoint, -c checkpoint to start the container from
|
|
||||||
--attach, -a connect to the stdio of the container
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ sudo ctr containers start redis /containers/redis
|
|
||||||
```
|
|
||||||
|
|
||||||
### Kill a container's process
|
### Kill a container's process
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ctr containers kill -h
|
$ ctr containers kill -h
|
||||||
NAME:
|
NAME:
|
||||||
kill - send a signal to a container or its processes
|
ctr containers kill - send a signal to a container or its processes
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
command kill [command options] [arguments...]
|
ctr containers kill [command options] [arguments...]
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--pid, -p "0" pid of the process to signal within the container
|
--pid, -p "init" pid of the process to signal within the container
|
||||||
--signal, -s "15" signal to send to the container
|
--signal, -s "15" signal to send to the container
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -220,20 +216,20 @@ OPTIONS:
|
||||||
```
|
```
|
||||||
$ ctr containers exec -h
|
$ ctr containers exec -h
|
||||||
NAME:
|
NAME:
|
||||||
exec - exec another process in an existing container
|
ctr containers exec - exec another process in an existing container
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
command exec [command options] [arguments...]
|
ctr containers exec [command options] [arguments...]
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--id container id to add the process to
|
--id container id to add the process to
|
||||||
|
--pid process id for the new process
|
||||||
--attach, -a connect to the stdio of the container
|
--attach, -a connect to the stdio of the container
|
||||||
--cwd current working directory for the process
|
--cwd current working directory for the process
|
||||||
--tty, -t create a terminal for the process
|
--tty, -t create a terminal for the process
|
||||||
--env, -e [--env option --env option] environment variables for the process
|
--env, -e [--env option --env option] environment variables for the process
|
||||||
--uid, -u "0" user id of the user for the process
|
--uid, -u "0" user id of the user for the process
|
||||||
--gid, -g "0" group id of the user for the process
|
--gid, -g "0" group id of the user for the process
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stats for a container
|
### Stats for a container
|
||||||
|
@ -241,10 +237,10 @@ OPTIONS:
|
||||||
```
|
```
|
||||||
$ ctr containers stats -h
|
$ ctr containers stats -h
|
||||||
NAME:
|
NAME:
|
||||||
stats - get stats for running container
|
ctr containers stats - get stats for running container
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
command stats [arguments...]
|
ctr containers stats [arguments...]
|
||||||
```
|
```
|
||||||
|
|
||||||
### List checkpoints
|
### List checkpoints
|
||||||
|
@ -261,17 +257,16 @@ test2 false false false
|
||||||
```
|
```
|
||||||
$ ctr checkpoints create -h
|
$ ctr checkpoints create -h
|
||||||
NAME:
|
NAME:
|
||||||
create - create a new checkpoint for the container
|
ctr checkpoints create - create a new checkpoint for the container
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
command create [command options] [arguments...]
|
ctr checkpoints create [command options] [arguments...]
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--tcp persist open tcp connections
|
--tcp persist open tcp connections
|
||||||
--unix-sockets perist unix sockets
|
--unix-sockets perist unix sockets
|
||||||
--exit exit the container after the checkpoint completes successfully
|
--exit exit the container after the checkpoint completes successfully
|
||||||
--shell checkpoint shell jobs
|
--shell checkpoint shell jobs
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get events
|
### Get events
|
||||||
|
|
|
@ -18,15 +18,15 @@ message CreateContainerRequest {
|
||||||
string stdin = 3; // path to the file where stdin will be read (optional)
|
string stdin = 3; // path to the file where stdin will be read (optional)
|
||||||
string stdout = 4; // path to file where stdout will be written (optional)
|
string stdout = 4; // path to file where stdout will be written (optional)
|
||||||
string stderr = 5; // path to file where stderr will be written (optional)
|
string stderr = 5; // path to file where stderr will be written (optional)
|
||||||
string console = 6; // path to the console for a container (optional)
|
string console = 6; // path to the console for a container (optional)
|
||||||
string checkpoint = 7; // checkpoint name if you want to create immediate checkpoint (optional)
|
string checkpoint = 7; // checkpoint name if you want to create immediate checkpoint (optional)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Attach
|
## Attach
|
||||||
|
|
||||||
In order to have attach like functionality for your containers you use the same API request but named pipes or `fifo`s can be be used to achieve this type of functionality.
|
In order to have attach like functionality for your containers you use the same API request but named pipes or `fifo`s can be used to achieve this type of functionality.
|
||||||
The default CLI for containerd does this if you specify the `--attach` flag on `create`.
|
The default CLI for containerd does this if you specify the `--attach` flag on `create` or `start`.
|
||||||
It will create fifos for each of the containers stdio which the CLI can read and write to.
|
It will create fifos for each of the containers stdio which the CLI can read and write to.
|
||||||
This can be used to create an interactive session with the container, `bash` for example, or to have a blocking way to collect the container's STDIO and forward it to your logging facilities.
|
This can be used to create an interactive session with the container, `bash` for example, or to have a blocking way to collect the container's STDIO and forward it to your logging facilities.
|
||||||
|
|
||||||
|
|
367
docs/bundle.md
367
docs/bundle.md
|
@ -49,242 +49,159 @@ cli tool from the [runc](https://github.com/opencontainers/runc) repository.
|
||||||
|
|
||||||
|
|
||||||
You need to `cd` into the `redis` directory and run the `runc spec` command. After doing this you
|
You need to `cd` into the `redis` directory and run the `runc spec` command. After doing this you
|
||||||
should have two files created, `configs.json` and `runtime.json`. The directory structure should
|
should have a file `config.json` created. The directory structure should look like this:
|
||||||
look like this:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
/containers/redis
|
/containers/redis
|
||||||
├── config.json
|
├── config.json
|
||||||
├── rootfs/
|
└── rootfs/
|
||||||
└── runtime.json
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Edits
|
## Edits
|
||||||
|
|
||||||
We need to edit the config to add `redis-server` as the application to launch inside the container along with
|
We need to edit the config to add `redis-server` as the application to launch inside the container,
|
||||||
a few other settings. The resulting `config.json` should look like this:
|
and remove the network namespace so that you can connect to the redis server on your system.
|
||||||
|
The resulting `config.json` should look like this:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"ociVersion": "0.4.0",
|
||||||
"platform": {
|
"platform": {
|
||||||
"os": "linux",
|
"os": "linux",
|
||||||
"arch": "amd64"
|
"arch": "amd64"
|
||||||
},
|
},
|
||||||
"process": {
|
"process": {
|
||||||
"terminal": false,
|
"terminal": true,
|
||||||
"user": {
|
"user": {},
|
||||||
"uid": 1000,
|
"args": [
|
||||||
"gid": 1000
|
"redis-server", "--bind", "0.0.0.0"
|
||||||
},
|
],
|
||||||
"args": [
|
"env": [
|
||||||
"redis-server", "--bind", "0.0.0.0"
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
],
|
"TERM=xterm"
|
||||||
"env": [
|
],
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"cwd": "/",
|
||||||
"TERM=xterm"
|
"capabilities": [
|
||||||
],
|
"CAP_AUDIT_WRITE",
|
||||||
"cwd": ""
|
"CAP_KILL",
|
||||||
},
|
"CAP_NET_BIND_SERVICE"
|
||||||
"root": {
|
],
|
||||||
"path": "rootfs",
|
"rlimits": [
|
||||||
"readonly": false
|
{
|
||||||
},
|
"type": "RLIMIT_NOFILE",
|
||||||
"hostname": "shell",
|
"hard": 1024,
|
||||||
"mounts": [
|
"soft": 1024
|
||||||
{"name": "proc", "path": "/proc"},
|
}
|
||||||
{"name": "dev", "path": "/dev"},
|
],
|
||||||
{"name": "devpts", "path": "/dev/pts"},
|
"noNewPrivileges": true
|
||||||
{"name": "shm", "path": "/dev/shm"},
|
},
|
||||||
{"name": "mqueue", "path": "/dev/mqueue"},
|
"root": {
|
||||||
{"name": "sysfs", "path": "/sys"}
|
"path": "rootfs",
|
||||||
],
|
"readonly": true
|
||||||
"linux": {
|
},
|
||||||
"capabilities": [
|
"hostname": "runc",
|
||||||
"CAP_AUDIT_WRITE",
|
"mounts": [
|
||||||
"CAP_KILL",
|
{
|
||||||
"CAP_NET_BIND_SERVICE"
|
"destination": "/proc",
|
||||||
]
|
"type": "proc",
|
||||||
}
|
"source": "proc"
|
||||||
}
|
},
|
||||||
```
|
{
|
||||||
|
"destination": "/dev",
|
||||||
You will also want to edit the `runtime.json` file to remove the network namespace so that
|
"type": "tmpfs",
|
||||||
you can connect to the redis server on your system. The final result for the `runtime.json`
|
"source": "tmpfs",
|
||||||
file should look like this:
|
"options": [
|
||||||
|
"nosuid",
|
||||||
```json
|
"strictatime",
|
||||||
{
|
"mode=755",
|
||||||
"mounts": {
|
"size=65536k"
|
||||||
"dev": {
|
]
|
||||||
"type": "tmpfs",
|
},
|
||||||
"source": "tmpfs",
|
{
|
||||||
"options": [
|
"destination": "/dev/pts",
|
||||||
"nosuid",
|
"type": "devpts",
|
||||||
"strictatime",
|
"source": "devpts",
|
||||||
"mode=755",
|
"options": [
|
||||||
"size=65536k"
|
"nosuid",
|
||||||
]
|
"noexec",
|
||||||
},
|
"newinstance",
|
||||||
"devpts": {
|
"ptmxmode=0666",
|
||||||
"type": "devpts",
|
"mode=0620",
|
||||||
"source": "devpts",
|
"gid=5"
|
||||||
"options": [
|
]
|
||||||
"nosuid",
|
},
|
||||||
"noexec",
|
{
|
||||||
"newinstance",
|
"destination": "/dev/shm",
|
||||||
"ptmxmode=0666",
|
"type": "tmpfs",
|
||||||
"mode=0620",
|
"source": "shm",
|
||||||
"gid=5"
|
"options": [
|
||||||
]
|
"nosuid",
|
||||||
},
|
"noexec",
|
||||||
"mqueue": {
|
"nodev",
|
||||||
"type": "mqueue",
|
"mode=1777",
|
||||||
"source": "mqueue",
|
"size=65536k"
|
||||||
"options": [
|
]
|
||||||
"nosuid",
|
},
|
||||||
"noexec",
|
{
|
||||||
"nodev"
|
"destination": "/dev/mqueue",
|
||||||
]
|
"type": "mqueue",
|
||||||
},
|
"source": "mqueue",
|
||||||
"proc": {
|
"options": [
|
||||||
"type": "proc",
|
"nosuid",
|
||||||
"source": "proc",
|
"noexec",
|
||||||
"options": null
|
"nodev"
|
||||||
},
|
]
|
||||||
"shm": {
|
},
|
||||||
"type": "tmpfs",
|
{
|
||||||
"source": "shm",
|
"destination": "/sys",
|
||||||
"options": [
|
"type": "sysfs",
|
||||||
"nosuid",
|
"source": "sysfs",
|
||||||
"noexec",
|
"options": [
|
||||||
"nodev",
|
"nosuid",
|
||||||
"mode=1777",
|
"noexec",
|
||||||
"size=65536k"
|
"nodev",
|
||||||
]
|
"ro"
|
||||||
},
|
]
|
||||||
"sysfs": {
|
},
|
||||||
"type": "sysfs",
|
{
|
||||||
"source": "sysfs",
|
"destination": "/sys/fs/cgroup",
|
||||||
"options": [
|
"type": "cgroup",
|
||||||
"nosuid",
|
"source": "cgroup",
|
||||||
"noexec",
|
"options": [
|
||||||
"nodev"
|
"nosuid",
|
||||||
]
|
"noexec",
|
||||||
}
|
"nodev",
|
||||||
},
|
"relatime",
|
||||||
"linux": {
|
"ro"
|
||||||
"rlimits": [
|
]
|
||||||
{
|
}
|
||||||
"type": "RLIMIT_NOFILE",
|
],
|
||||||
"hard": 1024,
|
"hooks": {},
|
||||||
"soft": 1024
|
"linux": {
|
||||||
}
|
"resources": {
|
||||||
],
|
"devices": [
|
||||||
"resources": {
|
{
|
||||||
"disableOOMKiller": false,
|
"allow": false,
|
||||||
"memory": {
|
"access": "rwm"
|
||||||
"limit": 0,
|
}
|
||||||
"reservation": 0,
|
]
|
||||||
"swap": 0,
|
},
|
||||||
"kernel": 0
|
"namespaces": [
|
||||||
},
|
{
|
||||||
"cpu": {
|
"type": "pid"
|
||||||
"shares": 0,
|
},
|
||||||
"quota": 0,
|
{
|
||||||
"period": 0,
|
"type": "ipc"
|
||||||
"realtimeRuntime": 0,
|
},
|
||||||
"realtimePeriod": 0,
|
{
|
||||||
"cpus": "",
|
"type": "uts"
|
||||||
"mems": ""
|
},
|
||||||
},
|
{
|
||||||
"pids": {
|
"type": "mount"
|
||||||
"limit": 0
|
}
|
||||||
},
|
],
|
||||||
"blockIO": {
|
"devices": null
|
||||||
"blkioWeight": 0,
|
}
|
||||||
"blkioLeafWeight": 0,
|
|
||||||
"blkioWeightDevice": null,
|
|
||||||
"blkioThrottleReadBpsDevice": null,
|
|
||||||
"blkioThrottleWriteBpsDevice": null,
|
|
||||||
"blkioThrottleReadIOPSDevice": null,
|
|
||||||
"blkioThrottleWriteIOPSDevice": null
|
|
||||||
},
|
|
||||||
"hugepageLimits": null,
|
|
||||||
"network": {
|
|
||||||
"classId": "",
|
|
||||||
"priorities": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"namespaces": [
|
|
||||||
{"type": "pid", "path": ""},
|
|
||||||
{"type": "ipc", "path": ""},
|
|
||||||
{"type": "uts", "path": ""},
|
|
||||||
{"type": "mount", "path": ""}
|
|
||||||
],
|
|
||||||
"devices": [
|
|
||||||
{
|
|
||||||
"path": "/dev/null",
|
|
||||||
"type": 99,
|
|
||||||
"major": 1,
|
|
||||||
"minor": 3,
|
|
||||||
"permissions": "rwm",
|
|
||||||
"fileMode": 438,
|
|
||||||
"uid": 0,
|
|
||||||
"gid": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/dev/random",
|
|
||||||
"type": 99,
|
|
||||||
"major": 1,
|
|
||||||
"minor": 8,
|
|
||||||
"permissions": "rwm",
|
|
||||||
"fileMode": 438,
|
|
||||||
"uid": 0,
|
|
||||||
"gid": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/dev/full",
|
|
||||||
"type": 99,
|
|
||||||
"major": 1,
|
|
||||||
"minor": 7,
|
|
||||||
"permissions": "rwm",
|
|
||||||
"fileMode": 438,
|
|
||||||
"uid": 0,
|
|
||||||
"gid": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/dev/tty",
|
|
||||||
"type": 99,
|
|
||||||
"major": 5,
|
|
||||||
"minor": 0,
|
|
||||||
"permissions": "rwm",
|
|
||||||
"fileMode": 438,
|
|
||||||
"uid": 0,
|
|
||||||
"gid": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/dev/zero",
|
|
||||||
"type": 99,
|
|
||||||
"major": 1,
|
|
||||||
"minor": 5,
|
|
||||||
"permissions": "rwm",
|
|
||||||
"fileMode": 438,
|
|
||||||
"uid": 0,
|
|
||||||
"gid": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/dev/urandom",
|
|
||||||
"type": 99,
|
|
||||||
"major": 1,
|
|
||||||
"minor": 9,
|
|
||||||
"permissions": "rwm",
|
|
||||||
"fileMode": 438,
|
|
||||||
"uid": 0,
|
|
||||||
"gid": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue