1crun(1)                     General Commands Manual                    crun(1)
2
3
4

NAME

6       crun - a fast and lightweight OCI runtime
7
8
9

SYNOPSIS

11       crun [global options] command [command options] [arguments...]
12
13
14

DESCRIPTION

16       crun is a command line program for running Linux containers that follow
17       the Open Container Initiative (OCI) format.
18
19
20

COMMANDS

22       create Create a container.  The runtime  detaches  from  the  container
23       process  once the container environment is created.  It is necessary to
24       successively use start for starting the container.
25
26
27       delete Remove definition for a container.
28
29
30       exec Exec a command in a running container.
31
32
33       list List known containers.
34
35
36       kill Send the specified signal to the container init  process.   If  no
37       signal is specified, SIGTERM is used.
38
39
40       ps Show the processes running in a container.
41
42
43       run Create and immediately start a container.
44
45
46       spec Generate a configuration file.
47
48
49       start  Start a container that was previously created.  A container can‐
50       not be started multiple times.
51
52
53       state Output the state of a container.
54
55
56       pause Pause all the processes in the container.
57
58
59       resume Resume the processes in the container.
60
61
62       update Update container resource constraints.
63
64
65       checkpoint Checkpoint a running container using CRIU
66
67
68       restore Restore a container from a checkpoint
69
70
71

STATE

73       By default, when running as root user, crun saves its state  under  the
74       /run/crun directory.  As unprivileged user, instead the XDG_RUNTIME_DIR
75       environment  variable  is  honored,   and   the   directory   $XDG_RUN‐
76       TIME_DIR/crun  is  used.   The global option --root overrides this set‐
77       ting.
78
79
80

GLOBAL OPTIONS

82       --debug Produce verbose output.
83
84
85       --log=LOG-DESTINATION Define the destination for the error and  warning
86       messages generated by crun.  If the error happens late in the container
87       init process, when crun already stopped watching it, then  it  will  be
88       printed to the container stderr.
89
90
91       It is specified in the form BACKEND:SPECIFIER.
92
93
94       These following backends are supported:
95
96
97              • file:PATH
98
99              • journald:IDENTIFIER
100
101              • syslog:IDENTIFIER
102
103
104
105       If no backend is specified, then file: is used by default.
106
107
108       --log-format=FORMAT  Define the format of the log messages.  It can ei‐
109       ther be text, or json.  The default is text.
110
111
112       --no-pivot Use chroot(2) instead of  pivot_root(2)  when  creating  the
113       container.  This option is not safe, and should be avoided.
114
115
116       --root=DIR Defines where to store the state for crun containers.
117
118
119       --systemd-cgroup  Use  systemd  for configuring cgroups.  If not speci‐
120       fied, the cgroup is created directly using the cgroupfs backend.
121
122
123       --cgroup-manager=MANAGER Specify what  cgroup  manager  must  be  used.
124       Permitted values are cgroupfs, systemd and disabled.
125
126
127       -?, --help Print a help list.
128
129
130       --usage Print a short usage message.
131
132
133       -V, --version Print program version
134
135

CREATE OPTIONS

137       crun [global options] create [options] CONTAINER
138
139
140       --bundle=PATH  Path to the OCI bundle, by default it is the current di‐
141       rectory.
142
143
144       --config=FILE Override the configuration  file  to  use.   The  default
145       value is config.json.
146
147
148       --console-socket=SOCKET  Path  to  a  UNIX socket that will receive the
149       ptmx end of the tty for the container.
150
151
152       --no-new-keyring Keep the same session key
153
154
155       --preserve-fds=N Additional number of FDs to pass into the container.
156
157
158       --pid-file=PATH Path to  the  file  that  will  contain  the  container
159       process PID.
160
161

RUN OPTIONS

163       crun [global options] run [options] CONTAINER
164
165
166       --bundle=BUNDLE  Path  to  the OCI bundle, by default it is the current
167       directory.
168
169
170       --config=FILE Override the configuration  file  to  use.   The  default
171       value is config.json.
172
173
174       --console-socket=SOCKET  Path  to  a  UNIX socket that will receive the
175       ptmx end of the tty for the container.
176
177
178       --no-new-keyring Keep the same session key.
179
180
181       --preserve-fds=N Additional number of FDs to pass into the container.
182
183
184       --pid-file=PATH Path to  the  file  that  will  contain  the  container
185       process PID.
186
187
188       --detach Detach the container process from the current session.
189
190

DELETE OPTIONS

192       crun [global options] delete [options] CONTAINER
193
194
195       --force Delete the container even if it is still running.
196
197
198       --regex=REGEX  Delete  all  the  containers  that satisfy the specified
199       regex.
200
201

EXEC OPTIONS

203       crun [global options] exec [options] CONTAINER CMD
204
205
206       --apparmor=PROFILE Set the apparmor profile for the process.
207
208
209       --console-socket=SOCKET Path to a UNIX socket  that  will  receive  the
210       ptmx end of the tty for the container.
211
212
213       --cwd=PATH Set the working directory for the process to PATH.
214
215
216       --cap=CAP Specify an additional capability to add to the process.
217
218
219       --detach Detach the container process from the current session.
220
221
222       --cgroup=PATH  Specify  a  sub-cgroup path inside the container cgroup.
223       The path must already exist in the container cgroup.
224
225
226       --env=ENV Specify an environment variable.
227
228
229       --no-new-privs Set the no new privileges value for the process.
230
231
232       --preserve-fds=N Additional number of FDs to pass into the container.
233
234
235       --process=FILE Path to a file containing the  process  JSON  configura‐
236       tion.
237
238
239       --process-label=VALUE  Set  the  asm process label for the process com‐
240       monly used with selinux.
241
242
243       --pid-file=PATH Path to the file that will contain the new process PID.
244
245
246       -t --tty Allocate a pseudo TTY.
247
248
249       **-u USERSPEC --user=USERSPEC Specify the user in the form UID[:GID].
250
251

LIST OPTIONS

253       crun [global options] list [options]
254
255
256       -q --quiet Show only the container ID.
257
258

KILL OPTIONS

260       crun [global options] kill [options] CONTAINER SIGNAL
261
262
263       --all Kill all the processes in the container.
264
265
266       --regex=REGEX Kill all the containers that satisfy the specified regex.
267
268

PS OPTIONS

270       crun [global options] ps [options]
271
272
273       --format=FORMAT Specify the output format.  It must be either table  or
274       json.  By default table is used.
275
276

SPEC OPTIONS

278       crun [global options] spec [options]
279
280
281       -b DIR --bundle=DIR Path to the root of the bundle dir (default ".").
282
283
284       --rootless  Generate  a  config.json file that is usable by an unprivi‐
285       leged user.
286
287

UPDATE OPTIONS

289       crun [global options] update [options] CONTAINER
290
291
292       --blkio-weight=VALUE Specifies per cgroup weight.
293
294
295       --cpu-period=VALUE CPU CFS period to be used for hardcapping.
296
297
298       --cpu-quota=VALUE CPU CFS hardcap limit.
299
300
301       --cpu-rt-period=VALUE CPU realtime period to be used for hardcapping.
302
303
304       --cpu-rt-runtime=VALUE CPU realtime hardcap limit.
305
306
307       --cpu-share=VALUE CPU shares.
308
309
310       --cpuset-cpus=VALUE CPU(s) to use.
311
312
313       --cpuset-mems=VALUE Memory node(s) to use.
314
315
316       --kernel-memory=VALUE Kernel memory limit.
317
318
319       --kernel-memory-tcp=VALUE Kernel memory limit for TCP buffer.
320
321
322       --memory=VALUE Memory limit.
323
324
325       --memory-reservation=VALUE Memory reservation or soft_limit.
326
327
328       --memory-swap=VALUE Total memory usage.
329
330
331       --pids-limit=VALUE Maximum number of pids allowed in the container.
332
333
334       -r, --resources=FILE Path to the file containing the resources  to  up‐
335       date.
336
337

CHECKPOINT OPTIONS

339       crun [global options] checkpoint [options] CONTAINER
340
341
342       --image-path=DIR Path for saving CRIU image files
343
344
345       --work-path=DIR Path for saving work files and logs
346
347
348       --leave-running Leave the process running after checkpointing
349
350
351       --tcp-established Allow open TCP connections
352
353
354       --ext-unix-sk Allow external UNIX sockets
355
356
357       --shell-job Allow shell jobs
358
359

RESTORE OPTIONS

361       crun [global options] restore [options] CONTAINER
362
363
364       -b DIR --bundle=DIR Container bundle directory (default ".")
365
366
367       --image-path=DIR Path for saving CRIU image files
368
369
370       --work-path=DIR Path for saving work files and logs
371
372
373       --tcp-established Allow open TCP connections
374
375
376       --ext-unix Allow external UNIX sockets
377
378
379       --shell-job Allow shell jobs
380
381
382       --detach Detach from the container's process
383
384
385       --pid-file=FILE Where to write the PID of the container
386
387
388

Extensions to OCI

run.oci.seccomp.receiver=PATH

391       If  the annotation run.oci.seccomp.receiver=PATH is specified, the sec‐
392       comp listener is sent to the UNIX socket  listening  on  the  specified
393       path.   It  can  also set with the RUN_OCI_SECCOMP_RECEIVER environment
394       variable.  It is an experimental feature, and the  annotation  will  be
395       removed  once  it is supported in the OCI runtime specs.  It must be an
396       absolute path.
397
398

run.oci.seccomp.plugins=PATH

400       If the annotation run.oci.seccomp.plugins=PLUGIN1[:PLUGIN2]... is spec‐
401       ified,  the  seccomp listener fd is handled through the specified plug‐
402       ins.  The plugin must either be an absolute path or a file name that is
403       looked  up  by  ldopen(3).   More information on how the lookup is per‐
404       formed are available on the ld.so(8) man page.
405
406

run.oci.seccomp_fail_unknown_syscall=1

408       If the annotation run.oci.seccomp_fail_unknown_syscall is present, then
409       crun  will  fail  when an unknown syscall is encountered in the seccomp
410       configuration.
411
412

run.oci.seccomp_bpf_data=PATH

414       If the annotation run.oci.seccomp_bpf_data is present,  then  crun  ig‐
415       nores  the  seccomp  section  in the OCI configuration file and use the
416       specified data as the raw data to the  seccomp(SECCOMP_SET_MODE_FILTER)
417       syscall.  The data must be encoded in base64.
418
419
420       It  is an experimental feature, and the annotation will be removed once
421       it is supported in the OCI runtime specs.
422
423

run.oci.keep_original_groups=1

425       If the annotation run.oci.keep_original_groups is  present,  then  crun
426       will  skip  the  setgroups syscall that is used to either set the addi‐
427       tional groups specified in the OCI configuration, or to reset the  list
428       of additional groups if none is specified.
429
430

run.oci.systemd.force_cgroup_v1=/PATH

432       If  the  annotation  run.oci.systemd.force_cgroup_v1=/PATH  is present,
433       then crun will override the specified mount point /PATH with  a  cgroup
434       v1 mount made of a single hierarchy none,name=systemd.  It is useful to
435       run on a cgroup v2 system containers using older  versions  of  systemd
436       that lack support for cgroup v2.
437
438
439       Note:  Your  container  host  has  to  have the cgroup v1 mount already
440       present, otherwise this will not work. If you want to run the container
441       rootless, the user it runs under has to have permissions to this mount‐
442       point.
443
444
445       For example, as root:
446
447
448              mkdir /sys/fs/cgroup/systemd
449              mount cgroup -t cgroup /sys/fs/cgroup/systemd -o none,name=systemd,xattr
450              chown -R the_user.the_user /sys/fs/cgroup/systemd
451
452
453

run.oci.timens_offset=ID SEC NSEC

455       Specify the offset to be written to /proc/self/timens_offsets when cre‐
456       ating a time namespace.
457
458

run.oci.systemd.subgroup=SUBGROUP

460       Override  the name for the systemd sub cgroup created under the systemd
461       scope, so the final cgroup will be like:
462
463
464              /sys/fs/cgroup/$PATH/$SUBGROUP
465
466
467
468       When it is set to the empty string, a sub cgroup is not created.
469
470
471       If not specified, it defaults to container on cgroup v2, and to  ""  on
472       cgroup v1.
473
474
475       e.g.
476
477
478              /sys/fs/cgroup//system.slice/foo-352700.scope/container
479
480
481

run.oci.delegate-cgroup=DELEGATED-CGROUP

483       If  the  run.oci.systemd.subgroup  annotation is specified, yet another
484       sub-cgroup is created and the container process is moved here.
485
486
487              /sys/fs/cgroup/$PATH/$SUBGROUP/$DELEGATED-CGROUP
488
489
490
491       The runtime doesn't apply  any  limit  to  the  $DELEGATED-CGROUP  sub-
492       cgroup, the runtime uses only $PATH/$SUBGROUP.
493
494
495       The  container  payload  fully manages $DELEGATE-CGROUP, the limits ap‐
496       plied to $PATH/$SUBGROUP still applies to $DELEGATE-CGROUP.
497
498
499       Since cgroup delegation is not safe on cgroup v1, this option  is  sup‐
500       ported only on cgroup v2.
501
502

run.oci.hooks.stdout=FILE

504       If  the annotation run.oci.hooks.stdout is present, then crun will open
505       the specified file and use it as the stdout  for  the  hook  processes.
506       The  file  is opened in append mode and it is created if it doesn't al‐
507       ready exist.
508
509

run.oci.hooks.stderr=FILE

511       If the annotation run.oci.hooks.stderr is present, then crun will  open
512       the  specified  file  and  use it as the stderr for the hook processes.
513       The file is opened in append mode and it is created if it  doesn't  al‐
514       ready exist.
515
516

run.oci.handler=HANDLER

518       It is an experimental feature.
519
520
521       If specified, run the specified handler for execing the container.  The
522       only supported value is krun.  When krun is specified,  the  libkrun.so
523       shared  object  is  loaded and it is used to launch the container using
524       libkrun.
525
526

run.oci.handler=wasm

528       If specified, run the wasm handler for container.  Allows running  wasm
529       workload  natively. Accepts a .wasm binary as input and if .wat is pro‐
530       vided it will automatically compiled into a  wasm  module.   Stdout  of
531       wasm module is relayed back via crun.
532
533

tmpcopyup mount options

535       If the tmpcopyup option is specified for a tmpfs, then the path that is
536       shadowed by the tmpfs mount is recursively copied up to the  tmpfs  it‐
537       self.
538
539

Automatically create user namespace

541       When running as user different than root, an user namespace is automat‐
542       ically created even if it is not specified in  the  config  file.   The
543       current user is mapped to the ID 0 in the container, and any additional
544       id specified in the files /etc/subuid and /etc/subgid is  automatically
545       added starting with ID 1.
546
547

Intermediate user namespace

549       If  the  configuration  specifies a new user namespace made of a single
550       mapping to the root user, but either the UID or the GID are set as non‐
551       zero  then crun automatically creates another user namespace to map the
552       root user to the specified UID and GID.
553
554
555       It enables running unprivileged containers with UID and  GID  different
556       than  zero, even when a single UID and GID are available, e.g. rootless
557       users on a system without newuidmap/newgidmap.
558
559
560

CGROUP v2

562       Note: cgroup v2 does not yet support control of realtime processes  and
563       the cpu controller can only be enabled when all RT processes are in the
564       root cgroup. This will make crun fail while running alongside  RT  pro‐
565       cesses.
566
567
568       If  the  cgroup  configuration  found is for cgroup v1, crun attempts a
569       conversion when running on a cgroup v2 system.
570
571
572       These are the OCI resources currently supported with cgroup v2 and  how
573       they are converted when needed from the cgroup v1 configuration.
574
575

Memory controller

577       ┌────────────┬────────────────────┬──────────────────────┬──────────────────┐
578OCI (x)     cgroup 2 value (y) conversion           comment          
579       ├────────────┼────────────────────┼──────────────────────┼──────────────────┤
580       │limit       │ memory.max         │ y = x                │                  │
581       ├────────────┼────────────────────┼──────────────────────┼──────────────────┤
582       │swap        │ memory.swap.max    │ y = x - memory_limit │ the  swap  limit │
583       │            │                    │                      │ on cgroup v1 in‐ │
584       │            │                    │                      │ cludes  the mem‐ │
585       │            │                    │                      │ ory usage too    │
586       ├────────────┼────────────────────┼──────────────────────┼──────────────────┤
587       │reservation │ memory.low         │ y = x                │                  │
588       └────────────┴────────────────────┴──────────────────────┴──────────────────┘
589

PIDs controller

591       ┌────────┬────────────────────┬────────────┬─────────┐
592OCI (x) cgroup 2 value (y) conversion comment 
593       ├────────┼────────────────────┼────────────┼─────────┤
594       │limit   │ pids.max           │ y = x      │         │
595       └────────┴────────────────────┴────────────┴─────────┘
596

CPU controller

598       ┌────────┬────────────────────┬──────────────────┬──────────────────┐
599OCI (x) cgroup 2 value (y) conversion       comment          
600       ├────────┼────────────────────┼──────────────────┼──────────────────┤
601       │shares  │ cpu.weight         │ y = (1 +  ((x  - │                  │
602       │        │                    │ 2)   *  9999)  / │                  │
603       │        │                    │ 262142)          │                  │
604       ├────────┼────────────────────┼──────────────────┼──────────────────┤
605       │        │ convert       from │                  │                  │
606       │        │ [2-262144]      to │                  │                  │
607       │        │ [1-10000]          │                  │                  │
608       ├────────┼────────────────────┼──────────────────┼──────────────────┤
609       │period  │ cpu.max            │ y = x            │ period and quota │
610       │        │                    │                  │ are  written to‐ │
611       │        │                    │                  │ gether           │
612       ├────────┼────────────────────┼──────────────────┼──────────────────┤
613       │quota   │ cpu.max            │ y = x            │ period and quota │
614       │        │                    │                  │ are  written to‐ │
615       │        │                    │                  │ gether           │
616       └────────┴────────────────────┴──────────────────┴──────────────────┘
617

blkio controller

619       ┌──────────────┬────────────────────┬────────────┬─────────┐
620OCI (x)       cgroup 2 value (y) conversion comment 
621       ├──────────────┼────────────────────┼────────────┼─────────┤
622       │weight        │ io.bfq.weight      │ y = x      │         │
623       ├──────────────┼────────────────────┼────────────┼─────────┤
624       │weight_device │ io.bfq.weight      │ y = x      │         │
625       ├──────────────┼────────────────────┼────────────┼─────────┤
626       │rbps          │ io.max             │ y=x        │         │
627       ├──────────────┼────────────────────┼────────────┼─────────┤
628       │wbps          │ io.max             │ y=x        │         │
629       ├──────────────┼────────────────────┼────────────┼─────────┤
630       │riops         │ io.max             │ y=x        │         │
631       ├──────────────┼────────────────────┼────────────┼─────────┤
632       │wiops         │ io.max             │ y=x        │         │
633       └──────────────┴────────────────────┴────────────┴─────────┘
634

cpuset controller

636       ┌────────┬────────────────────┬────────────┬─────────┐
637OCI (x) cgroup 2 value (y) conversion comment 
638       ├────────┼────────────────────┼────────────┼─────────┤
639       │cpus    │ cpuset.cpus        │ y = x      │         │
640       ├────────┼────────────────────┼────────────┼─────────┤
641       │mems    │ cpuset.mems        │ y = x      │         │
642       └────────┴────────────────────┴────────────┴─────────┘
643

hugetlb controller

645       ┌────────────────┬────────────────────┬────────────┬─────────┐
646OCI (x)         cgroup 2 value (y) conversion comment 
647       ├────────────────┼────────────────────┼────────────┼─────────┤
648       │.limit_in_bytes │ hugetlb..max       │ y = x      │         │
649       └────────────────┴────────────────────┴────────────┴─────────┘
650
651
652                                 User Commands                         crun(1)
Impressum