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
360       --pre-dump  Only checkpoint the container's memory without stopping the
361       container.  It is not possible to restore a container from a  pre-dump.
362       A  pre-dump always needs a final checkpoint (without --pre-dump). It is
363       possible to make as many pre-dumps as necessary. For a second  pre-dump
364       or for a final checkpoint it is necessary to use --parent-path to point
365       crun (and thus CRIU) to the pre-dump.
366
367
368       --parent-path=DIR Doing multiple pre-dumps or the final checkpoint  af‐
369       ter  one or multiple pre-dumps requires that crun (and thus CRIU) knows
370       the location of the pre-dump. It is important to use  a  relative  path
371       from  the  actual  checkpoint  directory specified via --image-path. It
372       will fail if an absolute path is used.
373
374
375       --manage-cgroups-mode=MODE Specify which CRIU manage cgroup mode should
376       be  used. Permitted values are soft, ignore, full or strict. Default is
377       soft.
378
379

RESTORE OPTIONS

381       crun [global options] restore [options] CONTAINER
382
383
384       -b DIR --bundle=DIR Container bundle directory (default ".")
385
386
387       --image-path=DIR Path for saving CRIU image files
388
389
390       --work-path=DIR Path for saving work files and logs
391
392
393       --tcp-established Allow open TCP connections
394
395
396       --ext-unix Allow external UNIX sockets
397
398
399       --shell-job Allow shell jobs
400
401
402       --detach Detach from the container's process
403
404
405       --pid-file=FILE Where to write the PID of the container
406
407
408       --manage-cgroups-mode=MODE Specify which CRIU manage cgroup mode should
409       be  used. Permitted values are soft, ignore, full or strict. Default is
410       soft.
411
412
413

Extensions to OCI

run.oci.seccomp.receiver=PATH

416       If the annotation run.oci.seccomp.receiver=PATH is specified, the  sec‐
417       comp  listener  is  sent  to the UNIX socket listening on the specified
418       path.  It can also set with  the  RUN_OCI_SECCOMP_RECEIVER  environment
419       variable.   It  is  an experimental feature, and the annotation will be
420       removed once it is supported in the OCI runtime specs.  It must  be  an
421       absolute path.
422
423

run.oci.seccomp.plugins=PATH

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

run.oci.seccomp_fail_unknown_syscall=1

433       If the annotation run.oci.seccomp_fail_unknown_syscall is present, then
434       crun will fail when an unknown syscall is encountered  in  the  seccomp
435       configuration.
436
437

run.oci.seccomp_bpf_data=PATH

439       If  the  annotation  run.oci.seccomp_bpf_data is present, then crun ig‐
440       nores the seccomp section in the OCI configuration  file  and  use  the
441       specified  data as the raw data to the seccomp(SECCOMP_SET_MODE_FILTER)
442       syscall.  The data must be encoded in base64.
443
444
445       It is an experimental feature, and the annotation will be removed  once
446       it is supported in the OCI runtime specs.
447
448

run.oci.keep_original_groups=1

450       If  the  annotation  run.oci.keep_original_groups is present, then crun
451       will skip the setgroups syscall that is used to either  set  the  addi‐
452       tional  groups specified in the OCI configuration, or to reset the list
453       of additional groups if none is specified.
454
455

run.oci.systemd.force_cgroup_v1=/PATH

457       If the  annotation  run.oci.systemd.force_cgroup_v1=/PATH  is  present,
458       then  crun  will override the specified mount point /PATH with a cgroup
459       v1 mount made of a single hierarchy none,name=systemd.  It is useful to
460       run  on  a  cgroup v2 system containers using older versions of systemd
461       that lack support for cgroup v2.
462
463
464       Note: Your container host has to  have  the  cgroup  v1  mount  already
465       present, otherwise this will not work. If you want to run the container
466       rootless, the user it runs under has to have permissions to this mount‐
467       point.
468
469
470       For example, as root:
471
472
473              mkdir /sys/fs/cgroup/systemd
474              mount cgroup -t cgroup /sys/fs/cgroup/systemd -o none,name=systemd,xattr
475              chown -R the_user.the_user /sys/fs/cgroup/systemd
476
477
478

run.oci.timens_offset=ID SEC NSEC

480       Specify the offset to be written to /proc/self/timens_offsets when cre‐
481       ating a time namespace.
482
483

run.oci.systemd.subgroup=SUBGROUP

485       Override the name for the systemd sub cgroup created under the  systemd
486       scope, so the final cgroup will be like:
487
488
489              /sys/fs/cgroup/$PATH/$SUBGROUP
490
491
492
493       When it is set to the empty string, a sub cgroup is not created.
494
495
496       If  not  specified, it defaults to container on cgroup v2, and to "" on
497       cgroup v1.
498
499
500       e.g.
501
502
503              /sys/fs/cgroup//system.slice/foo-352700.scope/container
504
505
506

run.oci.delegate-cgroup=DELEGATED-CGROUP

508       If the run.oci.systemd.subgroup annotation is  specified,  yet  another
509       sub-cgroup is created and the container process is moved here.
510
511
512              /sys/fs/cgroup/$PATH/$SUBGROUP/$DELEGATED-CGROUP
513
514
515
516       The  runtime  doesn't  apply  any  limit  to the $DELEGATED-CGROUP sub-
517       cgroup, the runtime uses only $PATH/$SUBGROUP.
518
519
520       The container payload fully manages $DELEGATE-CGROUP,  the  limits  ap‐
521       plied to $PATH/$SUBGROUP still applies to $DELEGATE-CGROUP.
522
523
524       Since  cgroup  delegation is not safe on cgroup v1, this option is sup‐
525       ported only on cgroup v2.
526
527

run.oci.hooks.stdout=FILE

529       If the annotation run.oci.hooks.stdout is present, then crun will  open
530       the  specified  file  and  use it as the stdout for the hook processes.
531       The file is opened in append mode and it is created if it  doesn't  al‐
532       ready exist.
533
534

run.oci.hooks.stderr=FILE

536       If  the annotation run.oci.hooks.stderr is present, then crun will open
537       the specified file and use it as the stderr  for  the  hook  processes.
538       The  file  is opened in append mode and it is created if it doesn't al‐
539       ready exist.
540
541

run.oci.handler=HANDLER

543       It is an experimental feature.
544
545
546       If specified, run the specified handler for execing the container.  The
547       only  supported  value is krun.  When krun is specified, the libkrun.so
548       shared object is loaded and it is used to launch  the  container  using
549       libkrun.
550
551

run.oci.handler=wasm

553       If  specified, run the wasm handler for container.  Allows running wasm
554       workload natively. Accepts a .wasm binary as input and if .wat is  pro‐
555       vided  it  will  automatically  compiled into a wasm module.  Stdout of
556       wasm module is relayed back via crun.
557
558

tmpcopyup mount options

560       If the tmpcopyup option is specified for a tmpfs, then the path that is
561       shadowed  by  the tmpfs mount is recursively copied up to the tmpfs it‐
562       self.
563
564

r$FLAG mount options

566       If a r$FLAG mount option is specified then the flag $FLAG is set recur‐
567       sively for each children mount.
568
569
570       These flags are supported:
571
572
573              • "rro"
574
575              • "rrw"
576
577              • "rsuid"
578
579              • "rnosuid"
580
581              • "rdev"
582
583              • "rnodev"
584
585              • "rexec"
586
587              • "rnoexec"
588
589              • "rsync"
590
591              • "rasync"
592
593              • "rdirsync"
594
595              • "rmand"
596
597              • "rnomand"
598
599              • "ratime"
600
601              • "rnoatime"
602
603              • "rdiratime"
604
605              • "rnodiratime"
606
607              • "rrelatime"
608
609              • "rnorelatime"
610
611              • "rstrictatime"
612
613              • "rnostrictatime"
614
615
616

idmap mount options

618       If  the idmap option is specified then the mount is ID mapped using the
619       container target user namespace.  This is an experimental  feature  and
620       can change at any time without notice.
621
622
623       The  idmap  option supports a custom mapping that can be different than
624       the user namespace used by the container.
625
626
627       The  mapping  can  be  specified   after   the   idmap   option   like:
628       idmap=uids=0-1-10#10-11-10;gids=0-100-10.
629
630
631       For each triplet, the first value is the start of the backing file sys‐
632       tem IDs that are mapped to the second value on the host.  The length of
633       this mapping is given in the third value.
634
635
636       Multiple ranges are separated with #.
637
638
639       These    values    are    written   to   the   /proc/$PID/uid_map   and
640       /proc/$PID/gid_map files to create the user namespace for the  idmapped
641       mount.
642
643
644       The  only two options that are currently supported after idmap are uids
645       and gids.
646
647
648       When a custom mapping is specified, a new user namespace is created for
649       the idmapped mount.
650
651
652       If no option is specified, then the container user namespace is used.
653
654
655       If  the  specified  mapping is prepended with a '@' then the mapping is
656       considered relative to the container user namespace.  The host  ID  for
657       the mapping is changed to account for the relative position of the con‐
658       tainer user in the container user namespace.
659
660
661       For example, the mapping: uids=@1-3-10, given a configuration like
662
663
664              "uidMappings": [
665                    {
666                      "containerID": 0,
667                      "hostID": 0,
668                      "size": 1
669                    },
670                    {
671                      "containerID": 1,
672                      "hostID": 2,
673                      "size": 1000
674                    }
675                  ]
676
677
678
679       will be converted to the absolute value uids=1-4-10, where 4 is  calcu‐
680       lated  by  adding  3  (container ID in the uids= mapping) + 1 (hostID -
681       containerID for the user namespace mapping where  containerID  =  1  is
682       found).
683
684
685       The  current  implementation  doesn't  take  into account multiple user
686       namespace ranges, so it is the caller's responsibility to split a  map‐
687       ping  if  it overlaps multiple ranges in the user namespace.  In such a
688       case, there won't be any error reported.
689
690

Automatically create user namespace

692       When running as user different than root, an user namespace is automat‐
693       ically  created  even  if  it is not specified in the config file.  The
694       current user is mapped to the ID 0 in the container, and any additional
695       id  specified in the files /etc/subuid and /etc/subgid is automatically
696       added starting with ID 1.
697
698

Intermediate user namespace

700       If the configuration specifies a new user namespace made  of  a  single
701       mapping to the root user, but either the UID or the GID are set as non‐
702       zero then crun automatically creates another user namespace to map  the
703       root user to the specified UID and GID.
704
705
706       It  enables  running unprivileged containers with UID and GID different
707       than zero, even when a single UID and GID are available, e.g.  rootless
708       users on a system without newuidmap/newgidmap.
709
710
711

CGROUP v2

713       Note:  cgroup v2 does not yet support control of realtime processes and
714       the cpu controller can only be enabled when all RT processes are in the
715       root  cgroup.  This will make crun fail while running alongside RT pro‐
716       cesses.
717
718
719       If the cgroup configuration found is for cgroup  v1,  crun  attempts  a
720       conversion when running on a cgroup v2 system.
721
722
723       These  are the OCI resources currently supported with cgroup v2 and how
724       they are converted when needed from the cgroup v1 configuration.
725
726

Memory controller

728       ┌────────────┬────────────────────┬──────────────────────┬──────────────────┐
729OCI (x)     cgroup 2 value (y) conversion           comment          
730       ├────────────┼────────────────────┼──────────────────────┼──────────────────┤
731       │limit       │ memory.max         │ y = x                │                  │
732       ├────────────┼────────────────────┼──────────────────────┼──────────────────┤
733       │swap        │ memory.swap.max    │ y = x - memory_limit │ the  swap  limit │
734       │            │                    │                      │ on cgroup v1 in‐ │
735       │            │                    │                      │ cludes the  mem‐ │
736       │            │                    │                      │ ory usage too    │
737       ├────────────┼────────────────────┼──────────────────────┼──────────────────┤
738       │reservation │ memory.low         │ y = x                │                  │
739       └────────────┴────────────────────┴──────────────────────┴──────────────────┘
740

PIDs controller

742       ┌────────┬────────────────────┬────────────┬─────────┐
743OCI (x) cgroup 2 value (y) conversion comment 
744       ├────────┼────────────────────┼────────────┼─────────┤
745       │limit   │ pids.max           │ y = x      │         │
746       └────────┴────────────────────┴────────────┴─────────┘
747

CPU controller

749       ┌────────┬────────────────────┬──────────────────┬──────────────────┐
750OCI (x) cgroup 2 value (y) conversion       comment          
751       ├────────┼────────────────────┼──────────────────┼──────────────────┤
752       │shares  │ cpu.weight         │ y  =  (1 + ((x - │                  │
753       │        │                    │ 2)  *  9999)   / │                  │
754       │        │                    │ 262142)          │                  │
755       ├────────┼────────────────────┼──────────────────┼──────────────────┤
756       │        │ convert       from │                  │                  │
757       │        │ [2-262144]      to │                  │                  │
758       │        │ [1-10000]          │                  │                  │
759       ├────────┼────────────────────┼──────────────────┼──────────────────┤
760       │period  │ cpu.max            │ y = x            │ period and quota │
761       │        │                    │                  │ are written  to‐ │
762       │        │                    │                  │ gether           │
763       ├────────┼────────────────────┼──────────────────┼──────────────────┤
764       │quota   │ cpu.max            │ y = x            │ period and quota │
765       │        │                    │                  │ are written  to‐ │
766       │        │                    │                  │ gether           │
767       └────────┴────────────────────┴──────────────────┴──────────────────┘
768

blkio controller

770       ┌──────────────┬────────────────────┬────────────┬─────────┐
771OCI (x)       cgroup 2 value (y) conversion comment 
772       ├──────────────┼────────────────────┼────────────┼─────────┤
773       │weight        │ io.bfq.weight      │ y = x      │         │
774       ├──────────────┼────────────────────┼────────────┼─────────┤
775       │weight_device │ io.bfq.weight      │ y = x      │         │
776       ├──────────────┼────────────────────┼────────────┼─────────┤
777       │rbps          │ io.max             │ y=x        │         │
778       ├──────────────┼────────────────────┼────────────┼─────────┤
779       │wbps          │ io.max             │ y=x        │         │
780       ├──────────────┼────────────────────┼────────────┼─────────┤
781       │riops         │ io.max             │ y=x        │         │
782       ├──────────────┼────────────────────┼────────────┼─────────┤
783       │wiops         │ io.max             │ y=x        │         │
784       └──────────────┴────────────────────┴────────────┴─────────┘
785

cpuset controller

787       ┌────────┬────────────────────┬────────────┬─────────┐
788OCI (x) cgroup 2 value (y) conversion comment 
789       ├────────┼────────────────────┼────────────┼─────────┤
790       │cpus    │ cpuset.cpus        │ y = x      │         │
791       ├────────┼────────────────────┼────────────┼─────────┤
792       │mems    │ cpuset.mems        │ y = x      │         │
793       └────────┴────────────────────┴────────────┴─────────┘
794

hugetlb controller

796       ┌────────────────┬────────────────────┬────────────┬─────────┐
797OCI (x)         cgroup 2 value (y) conversion comment 
798       ├────────────────┼────────────────────┼────────────┼─────────┤
799       │.limit_in_bytes │ hugetlb..max       │ y = x      │         │
800       └────────────────┴────────────────────┴────────────┴─────────┘
801
802
803                                 User Commands                         crun(1)
Impressum