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