1package dockercompose
2
3import "list"
4
5// Compose Specification
6//
7// The Compose file is a YAML file defining a multi-containers based application.
8#Schema: {
9 @jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
10 @jsonschema(id="https://raw.githubusercontent.com/compose-spec/compose-spec/HEAD/schema/compose_spec.json")
11 close({
12 // declared for backward compatibility, ignored. Please remove it.
13 version?: string @deprecated()
14
15 // define the Compose project name, until user defines one explicitly.
16 name?: string
17
18 // compose sub-projects to be included.
19 include?: [...#include]
20
21 // The services that will be used by your application.
22 services?: close({
23
24 {[=~"^[a-zA-Z0-9._-]+$"]: #service}})
25
26 // Language models that will be used by your application.
27 models?: {
28 {[=~"^[a-zA-Z0-9._-]+$"]: #model}
29 ...
30 }
31
32 // Networks that are shared among multiple services.
33 networks?: {
34 {[=~"^[a-zA-Z0-9._-]+$"]: #network}
35 ...
36 }
37
38 // Named volumes that are shared among multiple services.
39 volumes?: close({
40
41 {[=~"^[a-zA-Z0-9._-]+$"]: #volume}})
42
43 // Secrets that are shared among multiple services.
44 secrets?: close({
45
46 {[=~"^[a-zA-Z0-9._-]+$"]: #secret}})
47
48 // Configurations that are shared among multiple services.
49 configs?: close({
50
51 {[=~"^[a-zA-Z0-9._-]+$"]: #config}})
52
53 // Jobs are containers that run to completion.
54 jobs?: close({
55
56 {[=~"^[a-zA-Z0-9._-]+$"]: #job}})
57
58 {[=~"^x-"]: _}
59 })
60
61 // Block IO limit for a specific device.
62 #blkio_limit: close({
63 // Path to the device (e.g., '/dev/sda').
64 path?: string
65
66 // Rate limit in bytes per second or IO operations per second.
67 rate?: int | string
68 })
69
70 // Block IO weight for a specific device.
71 #blkio_weight: close({
72 // Path to the device (e.g., '/dev/sda').
73 path?: string
74
75 // Relative weight for the device, between 10 and 1000.
76 weight?: int | string
77 })
78
79 // Command to run in the container, which can be specified as a string (shell
80 // form) or array (exec form).
81 #command: matchN(1, [null, string, [...string]])
82
83 // Config configuration for the Compose application.
84 #config: close({
85 // Custom name for this config.
86 name?: string
87
88 // Inline content of the config.
89 content?: string
90
91 // Name of an environment variable from which to get the config value.
92 environment?: string
93
94 // Path to a file containing the config value.
95 file?: string
96
97 // Specifies that this config already exists and was created outside of Compose.
98 external?: bool | string | {
99 // Specifies the name of the external config. Deprecated: use the 'name' property instead.
100 name?: string @deprecated()
101 ...
102 }
103
104 // Add metadata to the config using labels.
105 labels?: #list_or_dict
106
107 // Driver to use for templating the config's value.
108 template_driver?: string
109
110 {[=~"^x-"]: _}
111 })
112
113 // Attributes of a container specification shared by anything that runs a
114 // container: services, jobs, and run-to-completion init containers (pre_start
115 // hooks).
116 #container_spec: {
117 annotations?: #list_or_dict
118
119 // Block IO configuration for the service.
120 blkio_config?: close({
121 // Limit read rate (bytes per second) from a device.
122 device_read_bps?: [...#blkio_limit]
123
124 // Limit read rate (IO per second) from a device.
125 device_read_iops?: [...#blkio_limit]
126
127 // Limit write rate (bytes per second) to a device.
128 device_write_bps?: [...#blkio_limit]
129
130 // Limit write rate (IO per second) to a device.
131 device_write_iops?: [...#blkio_limit]
132
133 // Block IO weight (relative weight) for the service, between 10 and 1000.
134 weight?: int | string
135
136 // Block IO weight (relative weight) for specific devices.
137 weight_device?: [...#blkio_weight]
138 })
139
140 // Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'.
141 cap_add?: list.UniqueItems() & [...string]
142
143 // Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'.
144 cap_drop?: list.UniqueItems() & [...string]
145
146 // Specify the cgroup namespace to join. Use 'host' to use the host's cgroup
147 // namespace, or 'private' to use a private cgroup namespace.
148 cgroup?: "host" | "private"
149
150 // Specify an optional parent cgroup for the container.
151 cgroup_parent?: string
152
153 // Override the default command declared by the container image, for example 'CMD' in Dockerfile.
154 command?: #command
155
156 // Grant access to Configs on a per-service basis.
157 configs?: #service_config_or_secret
158
159 // Number of usable CPUs.
160 cpu_count?: matchN(1, [string, int & >=0])
161
162 // Percentage of CPU resources to use.
163 cpu_percent?: matchN(1, [string, int & >=0 & <=100])
164
165 // CPU shares (relative weight) for the container.
166 cpu_shares?: number | string
167
168 // Limit the CPU CFS (Completely Fair Scheduler) quota.
169 cpu_quota?: number | string
170
171 // Limit the CPU CFS (Completely Fair Scheduler) period.
172 cpu_period?: number | string
173
174 // Limit the CPU real-time period in microseconds or a duration.
175 cpu_rt_period?: number | string
176
177 // Limit the CPU real-time runtime in microseconds or a duration.
178 cpu_rt_runtime?: number | string
179
180 // Number of CPUs to use. A floating-point value is supported to request partial CPUs.
181 cpus?: number | string
182
183 // CPUs in which to allow execution (0-3, 0,1).
184 cpuset?: string
185
186 // Configure the credential spec for managed service account.
187 credential_spec?: close({
188 // The name of the credential spec Config to use.
189 config?: string
190
191 // Path to a credential spec file.
192 file?: string
193
194 // Path to a credential spec in the Windows registry.
195 registry?: string
196
197 {[=~"^x-"]: _}
198 })
199
200 // Add rules to the cgroup allowed devices list.
201 device_cgroup_rules?: #list_of_strings
202
203 // List of device mappings for the container.
204 devices?: [...matchN(1, [
205 string,
206 close({
207 // Path on the host to the device.
208 source!: string
209
210 // Path in the container where the device will be mapped.
211 target?: string
212
213 // Cgroup permissions for the device (rwm).
214 permissions?: string
215
216 {[=~"^x-"]: _}
217 })
218 ])]
219
220 // Custom DNS servers to set for the service container.
221 dns?: #string_or_list
222
223 // Custom DNS options to be passed to the container's DNS resolver.
224 dns_opt?: list.UniqueItems() & [...string]
225
226 // Custom DNS search domains to set on the service container.
227 dns_search?: #string_or_list
228
229 // Custom domain name to use for the service container.
230 domainname?: string
231
232 // Override the default entrypoint declared by the container image, for example
233 // 'ENTRYPOINT' in Dockerfile.
234 entrypoint?: #command
235
236 // Add environment variables from a file or multiple files. Can be a single file
237 // path or a list of file paths.
238 env_file?: #env_file
239
240 // Add metadata to containers using files containing Docker labels.
241 label_file?: #label_file
242
243 // Add environment variables. You can use either an array or a list of KEY=VAL pairs.
244 environment?: #list_or_dict
245
246 // Add hostname mappings to the container network interface configuration.
247 extra_hosts?: #extra_hosts
248
249 // Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of
250 // specific GPU devices.
251 gpus?: #gpus
252
253 // Add additional groups which user inside the container should be member of.
254 group_add?: list.UniqueItems() & [...number | string]
255
256 // Define a custom hostname for the service container.
257 hostname?: string
258
259 // Specify the image to start the container from. Can be a repository/tag, a
260 // digest, or a local image ID.
261 image?: string
262
263 // Run as an init process inside the container that forwards signals and reaps processes.
264 init?: bool | string
265
266 // IPC sharing mode for the service container. Use 'host' to share the host's
267 // IPC namespace, 'service:[service_name]' to share with another service, or
268 // 'shareable' to allow other services to share this service's IPC namespace.
269 ipc?: string
270
271 // Container isolation technology to use. Supported values are platform-specific.
272 isolation?: string
273
274 // Add metadata to containers using Docker labels. You can use either an array or a list.
275 labels?: #list_or_dict
276
277 // Logging configuration for the service.
278 logging?: close({
279 // Logging driver to use, such as 'json-file', 'syslog', 'journald', etc.
280 driver?: string
281
282 // Options for the logging driver.
283 options?: {
284 {[=~"^.+$"]: null | number | string}
285 ...
286 }
287
288 {[=~"^x-"]: _}
289 })
290
291 // Container MAC address to set.
292 mac_address?: string
293
294 // Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes.
295 mem_limit?: number | string
296
297 // Memory reservation for the container.
298 mem_reservation?: int | string
299
300 // Container memory swappiness as percentage (0 to 100).
301 mem_swappiness?: int | string
302
303 // Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap.
304 memswap_limit?: number | string
305
306 // Network mode. Values can be 'bridge', 'host', 'none', 'service:[service
307 // name]', or 'container:[container name]'.
308 network_mode?: string
309
310 // AI Models to use, referencing entries under the top-level models key.
311 models?: matchN(1, [
312 #list_of_strings,
313 {
314 {
315 [=~"^[a-zA-Z0-9._-]+$"]: matchN(1, [
316 close({
317 // Environment variable set to AI model endpoint.
318 endpoint_var?: string
319
320 // Environment variable set to AI model name.
321 model_var?: string
322
323 {[=~"^x-"]: _}
324 }),
325 null
326 ])
327 }
328 ...
329 }
330 ])
331
332 // Networks to join, referencing entries under the top-level networks key. Can
333 // be a list of network names or a mapping of network name to network
334 // configuration.
335 networks?: matchN(1, [
336 #list_of_strings,
337 close({
338
339 {
340 [=~"^[a-zA-Z0-9._-]+$"]: matchN(1, [
341 close({
342 // Alternative hostnames for this service on the network.
343 aliases?: #list_of_strings
344
345 // Interface network name used to connect to network
346 interface_name?: string
347
348 // Specify a static IPv4 address for this service on this network.
349 ipv4_address?: string
350
351 // Specify a static IPv6 address for this service on this network.
352 ipv6_address?: string
353
354 // List of link-local IPs.
355 link_local_ips?: #list_of_strings
356
357 // Specify a MAC address for this service on this network.
358 mac_address?: string
359
360 // Driver options for this network.
361 driver_opts?: {
362 {[=~"^.+$"]: number | string}
363 ...
364 }
365
366 // Specify the priority for the network connection.
367 priority?: number
368
369 // Specify the gateway priority for the network connection.
370 gw_priority?: number
371
372 {[=~"^x-"]: _}
373 }),
374 null
375 ])
376 }})
377 ])
378
379 // Disable OOM Killer for the container.
380 oom_kill_disable?: bool | string
381
382 // Tune host's OOM preferences for the container (accepts -1000 to 1000).
383 oom_score_adj?: matchN(1, [string, int & >=-1000 & <=1000])
384
385 // PID mode for container.
386 pid?: null | string
387
388 // Tune a container's PIDs limit. Set to -1 for unlimited PIDs.
389 pids_limit?: number | string
390
391 // Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'.
392 platform?: string
393
394 // Give extended privileges to the service container.
395 privileged?: bool | string
396
397 // Policy for pulling images. Options include: 'always', 'never',
398 // 'if_not_present', 'missing', 'build', or time-based refresh policies.
399 pull_policy?: =~"^(always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+)$"
400
401 // Time after which to refresh the image. Used with pull_policy=refresh.
402 pull_refresh_after?: string
403
404 // Mount the container's filesystem as read only.
405 read_only?: bool | string
406
407 // Runtime to use for this container, e.g., 'runc'.
408 runtime?: string
409
410 // Override the default labeling scheme for each container.
411 security_opt?: list.UniqueItems() & [...string]
412
413 // Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes.
414 shm_size?: number | string
415
416 // Grant access to Secrets on a per-service basis.
417 secrets?: #service_config_or_secret
418
419 // Kernel parameters to set in the container. You can use either an array or a list.
420 sysctls?: #list_or_dict
421
422 // Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s').
423 stop_grace_period?: string
424
425 // Signal to stop the container (e.g., 'SIGTERM', 'SIGINT').
426 stop_signal?: string
427
428 // Storage driver options for the container.
429 storage_opt?: {...}
430
431 // Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list.
432 tmpfs?: #string_or_list
433
434 // Override the default ulimits for a container.
435 ulimits?: #ulimits
436
437 // Bind mount Docker API socket and required auth.
438 use_api_socket?: bool
439
440 // Username or UID to run the container process as.
441 user?: string
442
443 // UTS namespace to use. 'host' shares the host's UTS namespace.
444 uts?: string
445
446 // User namespace to use. 'host' shares the host's user namespace.
447 userns_mode?: string
448
449 // Mount host paths or named volumes accessible to the container. Short syntax
450 // (VOLUME:CONTAINER_PATH[:MODE])
451 volumes?: list.UniqueItems() & [...matchN(1, [
452 string,
453 close({
454 // The mount type: bind for mounting host directories, volume for named volumes,
455 // tmpfs for temporary filesystems, cluster for cluster volumes, npipe for
456 // named pipes, or image for mounting from an image.
457 type!: "bind" | "volume" | "tmpfs" | "cluster" | "npipe" | "image"
458
459 // The source of the mount, a path on the host for a bind mount, a docker image
460 // reference for an image mount, or the name of a volume defined in the
461 // top-level volumes key. Not applicable for a tmpfs mount.
462 source?: string
463
464 // The path in the container where the volume is mounted.
465 target?: string
466
467 // Flag to set the volume as read-only.
468 read_only?: bool | string
469
470 // The consistency requirements for the mount. Available values are platform specific.
471 consistency?: string
472
473 // Configuration specific to bind mounts.
474 bind?: close({
475 // The propagation mode for the bind mount: 'shared', 'slave', 'private',
476 // 'rshared', 'rslave', or 'rprivate'.
477 propagation?: string
478
479 // Create the host path if it doesn't exist.
480 create_host_path?: bool | string
481
482 // Recursively mount the source directory.
483 recursive?: "enabled" | "disabled" | "writable" | "readonly"
484
485 // SELinux relabeling options: 'z' for shared content, 'Z' for private unshared content.
486 selinux?: "z" | "Z"
487
488 {[=~"^x-"]: _}
489 })
490
491 // Configuration specific to volume mounts.
492 volume?: close({
493 // Labels to apply to the volume.
494 labels?: #list_or_dict
495
496 // Flag to disable copying of data from a container when a volume is created.
497 nocopy?: bool | string
498
499 // Path within the volume to mount instead of the volume root.
500 subpath?: string
501
502 {[=~"^x-"]: _}
503 })
504
505 // Configuration specific to tmpfs mounts.
506 tmpfs?: close({
507 // Size of the tmpfs mount in bytes.
508 size?: matchN(1, [int & >=0, string])
509
510 // File mode of the tmpfs in octal.
511 mode?: number | string
512
513 {[=~"^x-"]: _}
514 })
515
516 // Configuration specific to image mounts.
517 image?: close({
518 // Path within the image to mount instead of the image root.
519 subpath?: string
520
521 {[=~"^x-"]: _}
522 })
523
524 {[=~"^x-"]: _}
525 })
526 ])]
527
528 // Mount volumes from another service or container. Optionally specify read-only
529 // access (ro) or read-write (rw).
530 volumes_from?: list.UniqueItems() & [...string]
531
532 // The working directory in which the entrypoint or command will be run
533 working_dir?: string
534
535 {[=~"^x-"]: _}
536 ...
537 }
538
539 // Deployment configuration for the service.
540 #deployment: null | close({
541 // Deployment mode for the service: 'replicated' (default) or 'global'.
542 mode?: string
543
544 // Endpoint mode for the service: 'vip' (default) or 'dnsrr'.
545 endpoint_mode?: string
546
547 // Number of replicas of the service container to run.
548 replicas?: int | string
549
550 // Labels to apply to the service.
551 labels?: #list_or_dict
552
553 // Configuration for rolling back a service update.
554 rollback_config?: close({
555 // The number of containers to rollback at a time. If set to 0, all containers
556 // rollback simultaneously.
557 parallelism?: int | string
558
559 // The time to wait between each container group's rollback (e.g., '1s', '1m30s').
560 delay?: string
561
562 // Action to take if a rollback fails: 'continue', 'pause'.
563 failure_action?: string
564
565 // Duration to monitor each task for failures after it is created (e.g., '1s', '1m30s').
566 monitor?: string
567
568 // Failure rate to tolerate during a rollback.
569 max_failure_ratio?: number | string
570
571 // Order of operations during rollbacks: 'stop-first' (default) or 'start-first'.
572 order?: "start-first" | "stop-first"
573
574 {[=~"^x-"]: _}
575 })
576
577 // Configuration for updating a service.
578 update_config?: close({
579 // The number of containers to update at a time.
580 parallelism?: int | string
581
582 // The time to wait between updating a group of containers (e.g., '1s', '1m30s').
583 delay?: string
584
585 // Action to take if an update fails: 'continue', 'pause', 'rollback'.
586 failure_action?: string
587
588 // Duration to monitor each updated task for failures after it is created (e.g., '1s', '1m30s').
589 monitor?: string
590
591 // Failure rate to tolerate during an update (0 to 1).
592 max_failure_ratio?: number | string
593
594 // Order of operations during updates: 'stop-first' (default) or 'start-first'.
595 order?: "start-first" | "stop-first"
596
597 {[=~"^x-"]: _}
598 })
599
600 // Resource constraints and reservations for the service.
601 resources?: close({
602 // Resource limits for the service containers.
603 limits?: close({
604 // Limit for how much of the available CPU resources, as number of cores, a container can use.
605 cpus?: number | string
606
607 // Limit on the amount of memory a container can allocate (e.g., '1g', '1024m').
608 memory?: string
609
610 // Maximum number of PIDs available to the container.
611 pids?: int | string
612
613 {[=~"^x-"]: _}
614 })
615
616 // Resource reservations for the service containers.
617 reservations?: close({
618 // Reservation for how much of the available CPU resources, as number of cores, a container can use.
619 cpus?: number | string
620
621 // Reservation on the amount of memory a container can allocate (e.g., '1g', '1024m').
622 memory?: string
623
624 // User-defined resources to reserve.
625 generic_resources?: #generic_resources
626
627 // Device reservations for the container.
628 devices?: #devices
629
630 {[=~"^x-"]: _}
631 })
632
633 {[=~"^x-"]: _}
634 })
635
636 // Restart policy for the service containers.
637 restart_policy?: close({
638 // Condition for restarting the container: 'none', 'on-failure', 'any'.
639 condition?: string
640
641 // Delay between restart attempts (e.g., '1s', '1m30s').
642 delay?: string
643
644 // Maximum number of restart attempts before giving up.
645 max_attempts?: int | string
646
647 // Time window used to evaluate the restart policy (e.g., '1s', '1m30s').
648 window?: string
649
650 {[=~"^x-"]: _}
651 })
652
653 // Constraints and preferences for the platform to select a physical node to run service containers
654 placement?: close({
655 // Placement constraints for the service (e.g., 'node.role==manager').
656 constraints?: [...string]
657
658 // Placement preferences for the service.
659 preferences?: [...close({
660 // Spread tasks evenly across values of the specified node label.
661 spread?: string
662
663 {[=~"^x-"]: _}
664 })]
665
666 // Maximum number of replicas of the service.
667 max_replicas_per_node?: int | string
668
669 {[=~"^x-"]: _}
670 })
671
672 {[=~"^x-"]: _}
673 })
674
675 // Development configuration for the service, used for development workflows.
676 #development: null | close({
677 // Configure watch mode for the service, which monitors file changes and
678 // performs actions in response.
679 watch?: [...close({
680 // Patterns to exclude from watching.
681 ignore?: #string_or_list
682
683 // Patterns to include in watching.
684 include?: #string_or_list
685
686 // Path to watch for changes.
687 path!: string
688
689 // Action to take when a change is detected: rebuild the container, sync files,
690 // restart the container, sync and restart, or sync and execute a command.
691 action!: "rebuild" | "sync" | "restart" | "sync+restart" | "sync+exec"
692
693 // Target path in the container for sync operations.
694 target?: string
695
696 // Command to execute when a change is detected and action is sync+exec.
697 exec?: #service_hook
698
699 // Ensure that an initial synchronization is done before starting watch mode for sync+x triggers
700 initial_sync?: bool
701
702 {[=~"^x-"]: _}
703 })]
704
705 {[=~"^x-"]: _}
706 })
707
708 // Device reservations for containers, allowing services to access specific hardware devices.
709 #devices: [...close({
710 // List of capabilities the device needs to have (e.g., 'gpu', 'compute', 'utility').
711 capabilities!: #list_of_strings
712
713 // Number of devices of this type to reserve.
714 count?: int | string
715
716 // List of specific device IDs to reserve.
717 device_ids?: #list_of_strings
718
719 // Device driver to use (e.g., 'nvidia').
720 driver?: string
721
722 // Driver-specific options for the device.
723 options?: #list_or_dict
724
725 {[=~"^x-"]: _}
726 })]
727
728 #env_file: matchN(1, [
729 string,
730 [...matchN(1, [
731 string,
732 close({
733 // Path to the environment file.
734 path!: string
735
736 // Format attribute lets you to use an alternative file formats for env_file.
737 // When not set, env_file is parsed according to Compose rules.
738 format?: string
739
740 // Whether the file is required. If true and the file doesn't exist, an error will be raised.
741 required?: bool | string
742 })
743 ])]
744 ])
745
746 // Additional hostnames to be defined in the container's /etc/hosts file.
747 #extra_hosts: matchN(1, [
748 close({
749
750 {[=~".+"]: matchN(1, [string, [...string]])}}),
751 list.UniqueItems() & [...string]
752 ])
753
754 // User-defined resources for services, allowing services to reserve specialized hardware resources.
755 #generic_resources: [...close({
756 // Specification for discrete (countable) resources.
757 discrete_resource_spec?: close({
758 // Type of resource (e.g., 'GPU', 'FPGA', 'SSD').
759 kind?: string
760
761 // Number of resources of this kind to reserve.
762 value?: number | string
763
764 {[=~"^x-"]: _}
765 })
766
767 {[=~"^x-"]: _}
768 })]
769
770 #gpus: matchN(1, [
771 "all",
772 [...{
773 // List of capabilities the GPU needs to have (e.g., 'compute', 'utility').
774 capabilities?: #list_of_strings
775
776 // Number of GPUs to use.
777 count?: int | string
778
779 // List of specific GPU device IDs to use.
780 device_ids?: #list_of_strings
781
782 // GPU driver to use (e.g., 'nvidia').
783 driver?: string
784
785 // Driver-specific options for the GPU.
786 options?: #list_or_dict
787 ...
788 }]
789 ])
790
791 // Configuration options to determine whether the container is healthy.
792 #healthcheck: close({
793 // Disable any container-specified healthcheck. Set to true to disable.
794 disable?: bool | string
795
796 // Time between running the check (e.g., '1s', '1m30s'). Default: 30s.
797 interval?: string
798
799 // Number of consecutive failures needed to consider the container as unhealthy. Default: 3.
800 retries?: number | string
801
802 // The test to perform to check container health. Can be a string or a list. The
803 // first item is either NONE, CMD, or CMD-SHELL. If it's CMD, the rest of the
804 // command is exec'd. If it's CMD-SHELL, the rest is run in the shell.
805 test?: matchN(1, [string, [...string]])
806
807 // Maximum time to allow one check to run (e.g., '1s', '1m30s'). Default: 30s.
808 timeout?: string
809
810 // Start period for the container to initialize before starting health-retries
811 // countdown (e.g., '1s', '1m30s'). Default: 0s.
812 start_period?: string
813
814 // Time between running the check during the start period (e.g., '1s', '1m30s').
815 // Default: interval value.
816 start_interval?: string
817
818 {[=~"^x-"]: _}
819 })
820
821 // Compose application or sub-projects to be included.
822 #include: matchN(1, [
823 string,
824 close({
825 // Path to the Compose application or sub-project files to include.
826 path?: #string_or_list
827
828 // Path to the environment files to use to define default values when
829 // interpolating variables in the Compose files being parsed.
830 env_file?: #string_or_list
831
832 // Path to resolve relative paths set in the Compose file
833 project_directory?: string
834 })
835 ])
836
837 // Configuration for a job. Jobs are containers that run to completion.
838 #job: #container_spec &
839 #workload_spec &
840 close({
841 // List of profiles for this job. When profiles are specified, the job is only
842 // active when the profile is activated.
843 profiles?: #list_of_strings
844
845 // Trigger conditions for the job. At least one trigger attribute must be
846 // declared. Setting manual to false forbids manual execution by an explicit
847 // run command.
848 triggers!: matchN(>=1, [{
849 manual!: _
850 ...
851 }, {
852 schedule!: _
853 ...
854 }]) & close({
855 // Whether the job can be triggered manually by an explicit run command.
856 // Defaults to true; an explicit false forbids manual execution.
857 manual?: bool | string
858
859 // List of schedules for the job.
860 schedule?: [...matchN(1, [string, #schedule])]
861
862 {[=~"^x-"]: _}
863 })
864 annotations?: _
865 blkio_config?: _
866 cap_add?: _
867 cap_drop?: _
868 cgroup?: _
869 cgroup_parent?: _
870 command?: _
871 configs?: _
872 cpu_count?: _
873 cpu_percent?: _
874 cpu_shares?: _
875 cpu_quota?: _
876 cpu_period?: _
877 cpu_rt_period?: _
878 cpu_rt_runtime?: _
879 cpus?: _
880 cpuset?: _
881 credential_spec?: _
882 device_cgroup_rules?: _
883 devices?: _
884 dns?: _
885 dns_opt?: _
886 dns_search?: _
887 domainname?: _
888 entrypoint?: _
889 env_file?: _
890 label_file?: _
891 environment?: _
892 extra_hosts?: _
893 gpus?: _
894 group_add?: _
895 hostname?: _
896 image?: _
897 init?: _
898 ipc?: _
899 isolation?: _
900 labels?: _
901 logging?: _
902 mac_address?: _
903 mem_limit?: _
904 mem_reservation?: _
905 mem_swappiness?: _
906 memswap_limit?: _
907 network_mode?: _
908 models?: _
909 networks?: _
910 oom_kill_disable?: _
911 oom_score_adj?: _
912 pid?: _
913 pids_limit?: _
914 platform?: _
915 privileged?: _
916 pull_policy?: _
917 pull_refresh_after?: _
918 read_only?: _
919 runtime?: _
920 security_opt?: _
921 shm_size?: _
922 secrets?: _
923 sysctls?: _
924 stop_grace_period?: _
925 stop_signal?: _
926 storage_opt?: _
927 tmpfs?: _
928 ulimits?: _
929 use_api_socket?: _
930 user?: _
931 uts?: _
932 userns_mode?: _
933 volumes?: _
934 volumes_from?: _
935 working_dir?: _
936 build?: _
937 depends_on?: _
938 healthcheck?: _
939 ports?: _
940 expose?: _
941 stdin_open?: _
942 tty?: _
943
944 {[=~"^x-"]: _}
945 })
946
947 #label_file: matchN(1, [string, [...string]])
948
949 // A list of unique string values.
950 #list_of_strings: list.UniqueItems() & [...string]
951
952 // Either a dictionary mapping keys to values, or a list of strings.
953 #list_or_dict: matchN(1, [
954 close({
955
956 {[=~".+"]: null | bool | number | string}}),
957 list.UniqueItems() & [...string]
958 ])
959
960 // Language Model for the Compose application.
961 #model: close({
962 // Custom name for this model.
963 name?: string
964
965 // Language Model to run.
966 model!: string
967 context_size?: int
968
969 // Raw runtime flags to pass to the inference engine.
970 runtime_flags?: [...string]
971
972 {[=~"^x-"]: _}
973 })
974
975 // Network configuration for the Compose application.
976 #network: null | close({
977 // Custom name for this network.
978 name?: string
979
980 // Specify which driver should be used for this network. Default is 'bridge'.
981 driver?: string
982
983 // Specify driver-specific options defined as key/value pairs.
984 driver_opts?: {
985 {[=~"^.+$"]: number | string}
986 ...
987 }
988
989 // Custom IP Address Management configuration for this network.
990 ipam?: close({
991 // Custom IPAM driver, instead of the default.
992 driver?: string
993
994 // List of IPAM configuration blocks.
995 config?: [...close({
996 // Subnet in CIDR format that represents a network segment.
997 subnet?: string
998
999 // Range of IPs from which to allocate container IPs.
1000 ip_range?: string
1001
1002 // IPv4 or IPv6 gateway for the subnet.
1003 gateway?: string
1004
1005 // Auxiliary IPv4 or IPv6 addresses used by Network driver.
1006 aux_addresses?: close({
1007
1008 {[=~"^.+$"]: string}})
1009
1010 {[=~"^x-"]: _}
1011 })]
1012
1013 // Driver-specific options for the IPAM driver.
1014 options?: close({
1015
1016 {[=~"^.+$"]: string}})
1017
1018 {[=~"^x-"]: _}
1019 })
1020
1021 // Specifies that this network already exists and was created outside of Compose.
1022 external?: bool |
1023 string |
1024 close({
1025 // Specifies the name of the external network. Deprecated: use the 'name' property instead.
1026 name?: string @deprecated()
1027
1028 {[=~"^x-"]: _}
1029 })
1030
1031 // Create an externally isolated network.
1032 internal?: bool | string
1033
1034 // Enable IPv4 networking.
1035 enable_ipv4?: bool | string
1036
1037 // Enable IPv6 networking.
1038 enable_ipv6?: bool | string
1039
1040 // If true, standalone containers can attach to this network.
1041 attachable?: bool | string
1042
1043 // Add metadata to the network using labels.
1044 labels?: #list_or_dict
1045
1046 {[=~"^x-"]: _}
1047 })
1048
1049 // Configuration for a pre_start init container, run to completion before the
1050 // service container starts. Accepts the full container specification; per
1051 // #656, attributes not set explicitly are inherited from the service:
1052 // collection attributes are completed by the hook's declarations (which win on
1053 // conflicts), scalar attributes are replaced.
1054 #pre_start_hook: #container_spec & close({
1055 // When true, the hook runs once per service replica instead of once per service.
1056 per_replica?: bool | string
1057 annotations?: _
1058 blkio_config?: _
1059 cap_add?: _
1060 cap_drop?: _
1061 cgroup?: _
1062 cgroup_parent?: _
1063 command?: _
1064 configs?: _
1065 cpu_count?: _
1066 cpu_percent?: _
1067 cpu_shares?: _
1068 cpu_quota?: _
1069 cpu_period?: _
1070 cpu_rt_period?: _
1071 cpu_rt_runtime?: _
1072 cpus?: _
1073 cpuset?: _
1074 credential_spec?: _
1075 device_cgroup_rules?: _
1076 devices?: _
1077 dns?: _
1078 dns_opt?: _
1079 dns_search?: _
1080 domainname?: _
1081 entrypoint?: _
1082 env_file?: _
1083 label_file?: _
1084 environment?: _
1085 extra_hosts?: _
1086 gpus?: _
1087 group_add?: _
1088 hostname?: _
1089 image?: _
1090 init?: _
1091 ipc?: _
1092 isolation?: _
1093 labels?: _
1094 logging?: _
1095 mac_address?: _
1096 mem_limit?: _
1097 mem_reservation?: _
1098 mem_swappiness?: _
1099 memswap_limit?: _
1100 network_mode?: _
1101 models?: _
1102 networks?: _
1103 oom_kill_disable?: _
1104 oom_score_adj?: _
1105 pid?: _
1106 pids_limit?: _
1107 platform?: _
1108 privileged?: _
1109 pull_policy?: _
1110 pull_refresh_after?: _
1111 read_only?: _
1112 runtime?: _
1113 security_opt?: _
1114 shm_size?: _
1115 secrets?: _
1116 sysctls?: _
1117 stop_grace_period?: _
1118 stop_signal?: _
1119 storage_opt?: _
1120 tmpfs?: _
1121 ulimits?: _
1122 use_api_socket?: _
1123 user?: _
1124 uts?: _
1125 userns_mode?: _
1126 volumes?: _
1127 volumes_from?: _
1128 working_dir?: _
1129
1130 {[=~"^x-"]: _}
1131 })
1132
1133 // Schedule configuration for a job trigger.
1134 #schedule: close({
1135 // Crontab expression to schedule the job (e.g. '0 * * * *' for every hour).
1136 cron!: string
1137
1138 // Timezone used to evaluate the cron expression (e.g. 'Europe/Paris'). Defaults
1139 // to the platform's local timezone.
1140 timezone?: string
1141
1142 // Policy applied when the schedule fires while a previous run is still in
1143 // progress: prevent the new run ('forbid', the default) or queue it ('queue').
1144 concurrency?: "forbid" | "queue"
1145
1146 // Policy applied to fires missed while the platform was unavailable: run a
1147 // single catch-up ('one', the default) or skip them ('skip').
1148 missed_fires?: "one" | "skip"
1149
1150 {[=~"^x-"]: _}
1151 })
1152
1153 // Secret configuration for the Compose application.
1154 #secret: close({
1155 // Custom name for this secret.
1156 name?: string
1157
1158 // Name of an environment variable from which to get the secret value.
1159 environment?: string
1160
1161 // Path to a file containing the secret value.
1162 file?: string
1163
1164 // Specifies that this secret already exists and was created outside of Compose.
1165 external?: bool | string | {
1166 // Specifies the name of the external secret.
1167 name?: string
1168 ...
1169 }
1170
1171 // Add metadata to the secret using labels.
1172 labels?: #list_or_dict
1173
1174 // Specify which secret driver should be used for this secret.
1175 driver?: string
1176
1177 // Specify driver-specific options.
1178 driver_opts?: {
1179 {[=~"^.+$"]: number | string}
1180 ...
1181 }
1182
1183 // Driver to use for templating the secret's value.
1184 template_driver?: string
1185
1186 {[=~"^x-"]: _}
1187 })
1188
1189 // Configuration for a service.
1190 #service: #container_spec &
1191 #workload_spec &
1192 close({
1193 deploy?: #deployment
1194 develop?: #development
1195
1196 // List of profiles for this service. When profiles are specified, services are
1197 // only started when the profile is activated.
1198 profiles?: #list_of_strings
1199
1200 // Restart policy for the service container. Options include: 'no', 'always',
1201 // 'on-failure', and 'unless-stopped'.
1202 restart?: string
1203
1204 // Number of containers to deploy for this service.
1205 scale?: int | string
1206 attach?: bool | string
1207
1208 // Specify a custom container name, rather than a generated default name.
1209 container_name?: =~"[a-zA-Z0-9][a-zA-Z0-9_.-]+"
1210
1211 // Specify a service which will not be manage by Compose directly, and delegate
1212 // its management to an external provider.
1213 provider?: close({
1214 // External component used by Compose to manage setup and teardown lifecycle of the service.
1215 type!: string
1216
1217 // Provider-specific options.
1218 options?: {
1219 {[=~"^.+$"]: matchN(1, [bool | number | string, [...bool | number | string]])}
1220 ...
1221 }
1222
1223 {[=~"^x-"]: _}
1224 })
1225
1226 // Extend another service, in the current file or another file.
1227 extends?: matchN(1, [
1228 string,
1229 close({
1230 // The name of the service to extend.
1231 service!: string
1232
1233 // The file path where the service to extend is defined.
1234 file?: string
1235 })
1236 ])
1237
1238 // Link to containers in another service. Either specify both the service name
1239 // and a link alias (SERVICE:ALIAS), or just the service name.
1240 links?: list.UniqueItems() & [...string]
1241
1242 // Link to services started outside this Compose application. Specify services
1243 // as <service_name>:<alias>.
1244 external_links?: list.UniqueItems() & [...string]
1245
1246 // Init containers to run to completion before the service container is started.
1247 // Each step runs in its own ephemeral container, in declared order; a non-zero
1248 // exit fails the bring-up of the service and its dependents.
1249 pre_start?: [...#pre_start_hook]
1250
1251 // Commands to run after the container starts. If any command fails, the container stops.
1252 post_start?: [...#service_hook]
1253
1254 // Commands to run before the container stops. If any command fails, the container stop is aborted.
1255 pre_stop?: [...#service_hook]
1256 annotations?: _
1257 blkio_config?: _
1258 cap_add?: _
1259 cap_drop?: _
1260 cgroup?: _
1261 cgroup_parent?: _
1262 command?: _
1263 configs?: _
1264 cpu_count?: _
1265 cpu_percent?: _
1266 cpu_shares?: _
1267 cpu_quota?: _
1268 cpu_period?: _
1269 cpu_rt_period?: _
1270 cpu_rt_runtime?: _
1271 cpus?: _
1272 cpuset?: _
1273 credential_spec?: _
1274 device_cgroup_rules?: _
1275 devices?: _
1276 dns?: _
1277 dns_opt?: _
1278 dns_search?: _
1279 domainname?: _
1280 entrypoint?: _
1281 env_file?: _
1282 label_file?: _
1283 environment?: _
1284 extra_hosts?: _
1285 gpus?: _
1286 group_add?: _
1287 hostname?: _
1288 image?: _
1289 init?: _
1290 ipc?: _
1291 isolation?: _
1292 labels?: _
1293 logging?: _
1294 mac_address?: _
1295 mem_limit?: _
1296 mem_reservation?: _
1297 mem_swappiness?: _
1298 memswap_limit?: _
1299 network_mode?: _
1300 models?: _
1301 networks?: _
1302 oom_kill_disable?: _
1303 oom_score_adj?: _
1304 pid?: _
1305 pids_limit?: _
1306 platform?: _
1307 privileged?: _
1308 pull_policy?: _
1309 pull_refresh_after?: _
1310 read_only?: _
1311 runtime?: _
1312 security_opt?: _
1313 shm_size?: _
1314 secrets?: _
1315 sysctls?: _
1316 stop_grace_period?: _
1317 stop_signal?: _
1318 storage_opt?: _
1319 tmpfs?: _
1320 ulimits?: _
1321 use_api_socket?: _
1322 user?: _
1323 uts?: _
1324 userns_mode?: _
1325 volumes?: _
1326 volumes_from?: _
1327 working_dir?: _
1328 build?: _
1329 depends_on?: _
1330 healthcheck?: _
1331 ports?: _
1332 expose?: _
1333 stdin_open?: _
1334 tty?: _
1335
1336 {[=~"^x-"]: _}
1337 })
1338
1339 // Configuration for service configs or secrets, defining how they are mounted in the container.
1340 #service_config_or_secret: [...matchN(1, [
1341 string,
1342 close({
1343 // Name of the config or secret as defined in the top-level configs or secrets section.
1344 source?: string
1345
1346 // Path in the container where the config or secret will be mounted. Defaults to
1347 // /<source> for configs and /run/secrets/<source> for secrets.
1348 target?: string
1349
1350 // UID of the file in the container. Default is 0 (root).
1351 uid?: string
1352
1353 // GID of the file in the container. Default is 0 (root).
1354 gid?: string
1355
1356 // File permission mode inside the container, in octal. Default is 0444 for
1357 // configs and 0400 for secrets.
1358 mode?: number | string
1359
1360 {[=~"^x-"]: _}
1361 })
1362 ])]
1363
1364 // Configuration for service lifecycle hooks, which are commands executed at
1365 // specific points in a container's lifecycle.
1366 #service_hook: close({
1367 // Command to execute as part of the hook.
1368 command!: #command
1369
1370 // User to run the command as.
1371 user?: string
1372
1373 // Whether to run the command with extended privileges.
1374 privileged?: bool | string
1375
1376 // Working directory for the command.
1377 working_dir?: string
1378
1379 // Environment variables for the command.
1380 environment?: #list_or_dict
1381
1382 {[=~"^x-"]: _}
1383 })
1384
1385 // Either a single string or a list of strings.
1386 #string_or_list: matchN(1, [string, #list_of_strings])
1387
1388 // Container ulimit options, controlling resource limits for processes inside the container.
1389 #ulimits: {
1390 {
1391 [=~"^[a-z]+$"]: matchN(1, [
1392 int | string,
1393 close({
1394 // Hard limit for the ulimit type. This is the maximum allowed value.
1395 hard!: int | string
1396
1397 // Soft limit for the ulimit type. This is the value that's actually enforced.
1398 soft!: int | string
1399
1400 {[=~"^x-"]: _}
1401 })
1402 ])
1403 }
1404 ...
1405 }
1406
1407 // Volume configuration for the Compose application.
1408 #volume: null | close({
1409 // Custom name for this volume.
1410 name?: string
1411
1412 // Specify which volume driver should be used for this volume.
1413 driver?: string
1414
1415 // Specify driver-specific options.
1416 driver_opts?: {
1417 {[=~"^.+$"]: number | string}
1418 ...
1419 }
1420
1421 // Specifies that this volume already exists and was created outside of Compose.
1422 external?: bool |
1423 string |
1424 close({
1425 // Specifies the name of the external volume. Deprecated: use the 'name' property instead.
1426 name?: string @deprecated()
1427
1428 {[=~"^x-"]: _}
1429 })
1430
1431 // Add metadata to the volume using labels.
1432 labels?: #list_or_dict
1433
1434 {[=~"^x-"]: _}
1435 })
1436
1437 // Container attributes meaningful for orchestrated workloads (services and
1438 // jobs) but not for run-to-completion init containers: build, dependency
1439 // ordering, health reporting, port exposure and interactivity.
1440 #workload_spec: {
1441 // Configuration options for building the service's image.
1442 build?: matchN(1, [
1443 string,
1444 close({
1445 // Path to the build context. Can be a relative path or a URL.
1446 context?: string
1447
1448 // Name of the Dockerfile to use for building the image.
1449 dockerfile?: string
1450
1451 // Inline Dockerfile content to use instead of a Dockerfile from the build context.
1452 dockerfile_inline?: string
1453
1454 // List of extra privileged entitlements to grant to the build process.
1455 entitlements?: [...string]
1456
1457 // Build-time variables, specified as a map or a list of KEY=VAL pairs.
1458 args?: #list_or_dict
1459
1460 // SSH agent socket or keys to expose to the build. Format is either a string or
1461 // a list of 'default|<id>[=<socket>|<key>[,<key>]]'.
1462 ssh?: #list_or_dict
1463
1464 // Labels to apply to the built image.
1465 labels?: #list_or_dict
1466
1467 // List of sources the image builder should use for cache resolution
1468 cache_from?: [...string]
1469
1470 // Cache destinations for the build cache.
1471 cache_to?: [...string]
1472
1473 // Do not use cache when building the image.
1474 no_cache?: bool | string
1475
1476 // Do not use build cache for the specified stages.
1477 no_cache_filter?: #string_or_list
1478
1479 // Additional build contexts to use, specified as a map of name to context path or URL.
1480 additional_contexts?: #list_or_dict
1481
1482 // Network mode to use for the build. Options include 'default', 'none', 'host', or a network name.
1483 network?: string
1484
1485 // Add a provenance attestation
1486 provenance?: bool | string
1487
1488 // Add a SBOM attestation
1489 sbom?: bool | string
1490
1491 // Always attempt to pull a newer version of the image.
1492 pull?: bool | string
1493
1494 // Build stage to target in a multi-stage Dockerfile.
1495 target?: string
1496
1497 // Size of /dev/shm for the build container. A string value can use suffix like
1498 // '2g' for 2 gigabytes.
1499 shm_size?: int | string
1500
1501 // Add hostname mappings for the build container.
1502 extra_hosts?: #extra_hosts
1503
1504 // Container isolation technology to use for the build process.
1505 isolation?: string
1506
1507 // Give extended privileges to the build container.
1508 privileged?: bool | string
1509
1510 // Secrets to expose to the build. These are accessible at build-time.
1511 secrets?: #service_config_or_secret
1512
1513 // Additional tags to apply to the built image.
1514 tags?: [...string]
1515
1516 // Override the default ulimits for the build container.
1517 ulimits?: #ulimits
1518
1519 // Platforms to build for, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'.
1520 platforms?: [...string]
1521
1522 {[=~"^x-"]: _}
1523 })
1524 ])
1525
1526 // Express dependency between services. Service dependencies cause services to
1527 // be started in dependency order. The dependent service will wait for the
1528 // dependency to be ready before starting.
1529 depends_on?: matchN(1, [
1530 #list_of_strings,
1531 close({
1532
1533 {
1534 [=~"^[a-zA-Z0-9._-]+$"]: close({
1535
1536 {[=~"^x-"]: _}
1537
1538 // Whether to restart dependent services when this service is restarted.
1539 restart?: bool | string
1540
1541 // Whether the dependency is required for the dependent service to start.
1542 required?: bool
1543
1544 // Condition to wait for. 'service_started' waits until the service has started,
1545 // 'service_healthy' waits until the service is healthy (as defined by its
1546 // healthcheck), 'service_completed_successfully' waits until the service has
1547 // completed successfully.
1548 condition!: "service_started" | "service_healthy" | "service_completed_successfully"
1549 })
1550 }})
1551 ])
1552
1553 // Configure a health check for the container to monitor its health status.
1554 healthcheck?: #healthcheck
1555
1556 // Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]).
1557 ports?: list.UniqueItems() & [...matchN(1, [
1558 number,
1559 string,
1560 close({
1561 // A human-readable name for this port mapping.
1562 name?: string
1563
1564 // The port binding mode, either 'host' for publishing a host port or 'ingress' for load balancing.
1565 mode?: string
1566
1567 // The host IP to bind to.
1568 host_ip?: string
1569
1570 // The port inside the container.
1571 target?: int | string
1572
1573 // The publicly exposed port.
1574 published?: int | string
1575
1576 // The port protocol (tcp or udp).
1577 protocol?: string
1578
1579 // Application protocol to use with the port (e.g., http, https, mysql).
1580 app_protocol?: string
1581
1582 {[=~"^x-"]: _}
1583 })
1584 ])]
1585
1586 // Expose ports without publishing them to the host machine - they'll only be
1587 // accessible to linked services.
1588 expose?: list.UniqueItems() & [...number | string]
1589
1590 // Keep STDIN open even if not attached.
1591 stdin_open?: bool | string
1592
1593 // Allocate a pseudo-TTY to service container.
1594 tty?: bool | string
1595
1596 {[=~"^x-"]: _}
1597 ...
1598 }
1599}