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.pidfd_receiver=PATH

457       It is an experimental feature and will be removed once the  feature  is
458       in the OCI runtime specs.
459
460
461       If  present,  specify the path to the UNIX socket that will receive the
462       pidfd for the container process.
463
464

run.oci.systemd.force_cgroup_v1=/PATH

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

run.oci.timens_offset=ID SEC NSEC

489       Specify the offset to be written to /proc/self/timens_offsets when cre‐
490       ating a time namespace.
491
492

run.oci.systemd.subgroup=SUBGROUP

494       Override the name for the systemd sub cgroup created under the  systemd
495       scope, so the final cgroup will be like:
496
497
498              /sys/fs/cgroup/$PATH/$SUBGROUP
499
500
501
502       When it is set to the empty string, a sub cgroup is not created.
503
504
505       If  not  specified, it defaults to container on cgroup v2, and to "" on
506       cgroup v1.
507
508
509       e.g.
510
511
512              /sys/fs/cgroup//system.slice/foo-352700.scope/container
513
514
515

run.oci.delegate-cgroup=DELEGATED-CGROUP

517       If the run.oci.systemd.subgroup annotation is  specified,  yet  another
518       sub-cgroup is created and the container process is moved here.
519
520
521       If  a  cgroup namespace is used, the cgroup namespace is created before
522       moving the container to the delegated cgroup.
523
524
525              /sys/fs/cgroup/$PATH/$SUBGROUP/$DELEGATED-CGROUP
526
527
528
529       The runtime doesn't apply  any  limit  to  the  $DELEGATED-CGROUP  sub-
530       cgroup, the runtime uses only $PATH/$SUBGROUP.
531
532
533       The  container  payload  fully manages $DELEGATE-CGROUP, the limits ap‐
534       plied to $PATH/$SUBGROUP still applies to $DELEGATE-CGROUP.
535
536
537       Since cgroup delegation is not safe on cgroup v1, this option  is  sup‐
538       ported only on cgroup v2.
539
540

run.oci.hooks.stdout=FILE

542       If  the annotation run.oci.hooks.stdout is present, then crun will open
543       the specified file and use it as the stdout  for  the  hook  processes.
544       The  file  is opened in append mode and it is created if it doesn't al‐
545       ready exist.
546
547

run.oci.hooks.stderr=FILE

549       If the annotation run.oci.hooks.stderr is present, then crun will  open
550       the  specified  file  and  use it as the stderr for the hook processes.
551       The file is opened in append mode and it is created if it  doesn't  al‐
552       ready exist.
553
554

run.oci.handler=HANDLER

556       It is an experimental feature.
557
558
559       If specified, run the specified handler for execing the container.  The
560       only supported values are krun and wasm.
561
562
563krun: When krun is specified, the libkrun.so shared object  is
564                loaded and it is used to launch the container using libkrun.
565
566wasm: If specified, run the wasm handler for container. Allows
567                running wasm workload natively. Accepts a .wasm binary as  in‐
568                put  and if .wat is provided it will be automatically compiled
569                into a wasm module. Stdout of wasm module is relayed back  via
570                crun.
571
572
573

tmpcopyup mount options

575       If the tmpcopyup option is specified for a tmpfs, then the path that is
576       shadowed by the tmpfs mount is recursively copied up to the  tmpfs  it‐
577       self.
578
579

r$FLAG mount options

581       If a r$FLAG mount option is specified then the flag $FLAG is set recur‐
582       sively for each children mount.
583
584
585       These flags are supported:
586
587
588              • "rro"
589
590              • "rrw"
591
592              • "rsuid"
593
594              • "rnosuid"
595
596              • "rdev"
597
598              • "rnodev"
599
600              • "rexec"
601
602              • "rnoexec"
603
604              • "rsync"
605
606              • "rasync"
607
608              • "rdirsync"
609
610              • "rmand"
611
612              • "rnomand"
613
614              • "ratime"
615
616              • "rnoatime"
617
618              • "rdiratime"
619
620              • "rnodiratime"
621
622              • "rrelatime"
623
624              • "rnorelatime"
625
626              • "rstrictatime"
627
628              • "rnostrictatime"
629
630
631

idmap mount options

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

Automatically create user namespace

707       When running as user different than root, an user namespace is automat‐
708       ically created even if it is not specified in  the  config  file.   The
709       current user is mapped to the ID 0 in the container, and any additional
710       id specified in the files /etc/subuid and /etc/subgid is  automatically
711       added starting with ID 1.
712
713
714

CGROUP v2

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

Memory controller

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

PIDs controller

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

CPU controller

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

blkio controller

773       ┌──────────────┬──────────────────────┬─────────────────────────┬──────────────────┐
774OCI (x)       cgroup 2 value (y)   conversion              comment          
775       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
776       │weight        │ io.bfq.weight        │ y = x                   │                  │
777       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
778       │weight_device │ io.bfq.weight        │ y = x                   │                  │
779       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
780       │weight        │ io.weight (fallback) │ y = 1 + (x-10)*9999/990 │ convert linearly │
781       │              │                      │                         │ from   [10-1000] │
782       │              │                      │                         │ to [1-10000]     │
783       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
784       │weight_device │ io.weight (fallback) │ y = 1 + (x-10)*9999/990 │ convert linearly │
785       │              │                      │                         │ from   [10-1000] │
786       │              │                      │                         │ to [1-10000]     │
787       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
788       │rbps          │ io.max               │ y=x                     │                  │
789       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
790       │wbps          │ io.max               │ y=x                     │                  │
791       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
792       │riops         │ io.max               │ y=x                     │                  │
793       ├──────────────┼──────────────────────┼─────────────────────────┼──────────────────┤
794       │wiops         │ io.max               │ y=x                     │                  │
795       └──────────────┴──────────────────────┴─────────────────────────┴──────────────────┘
796

cpuset controller

798       ┌────────┬────────────────────┬────────────┬─────────┐
799OCI (x) cgroup 2 value (y) conversion comment 
800       ├────────┼────────────────────┼────────────┼─────────┤
801       │cpus    │ cpuset.cpus        │ y = x      │         │
802       ├────────┼────────────────────┼────────────┼─────────┤
803       │mems    │ cpuset.mems        │ y = x      │         │
804       └────────┴────────────────────┴────────────┴─────────┘
805

hugetlb controller

807       ┌────────────────┬────────────────────┬────────────┬─────────┐
808OCI (x)         cgroup 2 value (y) conversion comment 
809       ├────────────────┼────────────────────┼────────────┼─────────┤
810       │.limit_in_bytes │ hugetlb..max       │ y = x      │         │
811       └────────────────┴────────────────────┴────────────┴─────────┘
812
813
814                                 User Commands                         crun(1)
Impressum