You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/manuals/compose/bridge/_index.md
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,22 +8,31 @@ weight: 50
8
8
9
9
{{< summary-bar feature_name="Compose bridge" >}}
10
10
11
-
Compose Bridge converts your Docker Compose configuration into platform-specific formats—primarily Kubernetes manifests. The default transformation generates Kubernetes manifests and a Kustomize overlay which are designed for deployment on Docker Desktop with Kubernetes enabled.
11
+
Compose Bridge converts your Docker Compose configuration into platform-specific deployment formats such as Kubernetes manifests. By default, it geneterates:
12
12
13
-
It's a flexible tool that lets you either take advantage of the [default transformation](usage.md) or [create a custom transformation](customize.md) to suit specific project needs and requirements.
13
+
- Kubernetes manifests
14
+
- A Kustomize overlay
14
15
15
-
Compose Bridge significantly simplifies the transition from Docker Compose to Kubernetes, making it easier for you to leverage the power of Kubernetes while maintaining the simplicity and efficiency of Docker Compose.
16
+
These outputs are ready for deployment on Docker Desktop with [Kubernetes enabled](/manuals/desktop/settings-and-maintenance/settings.md#kubernetes).
17
+
18
+
Compose Bridge helps you bridge the gap between Compose and Kubernetes, making it easier to adopt Kubernetes while keeping the simplicity and efficiency of Compose.
19
+
20
+
It's a flexible tool that lets you either take advantage of the [default transformation](usage.md) or [create a custom transformation](customize.md) to suit specific project needs and requirements.
16
21
17
22
## How it works
18
23
19
-
Compose Bridge uses transformations to let you convert a Compose model into another form.
24
+
Compose Bridge uses transformations to convert a Compose model into another form.
20
25
21
26
A transformation is packaged as a Docker image that receives the fully resolved Compose model as `/in/compose.yaml` and can produce any target format file under `/out`.
22
27
23
28
Compose Bridge provides its own transformation for Kubernetes using Go templates, so that it is easy to extend for customization by replacing or appending your own templates.
24
29
25
30
For more detailed information on how these transformations work and how you can customize them for your projects, see [Customize](customize.md).
26
31
32
+
Compose Bridge also supports applications that use LLMs via Docker Model Runner.
33
+
34
+
For more details, see [Use Model Runner](use-model-runner.md).
Copy file name to clipboardExpand all lines: content/manuals/compose/bridge/customize.md
+53-26Lines changed: 53 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,13 @@ linkTitle: Customize
4
4
weight: 20
5
5
description: Learn how to customize Compose Bridge transformations using Go templates and Compose extensions
6
6
keywords: docker compose bridge, customize compose bridge, compose bridge templates, compose to kubernetes, compose bridge transformation, go templates docker
7
-
8
7
---
9
8
10
9
{{< summary-bar feature_name="Compose bridge" >}}
11
10
12
-
This page explains how Compose Bridge utilizes templating to efficiently translate Docker Compose files into Kubernetes manifests. It also explains how you can customize these templates for your specific requirements and needs, or how you can build your own transformation.
11
+
You can customize how Compose Bridge converts your Docker Compose files into platform-specific formats.
12
+
13
+
This page explains how Compose Bridge uses templating to generate Kubernetes manifests and how you can customize these templates for your specific requirements and needs, or how you can build your own transformation.
13
14
14
15
## How it works
15
16
@@ -19,7 +20,7 @@ A transformation is packaged as a Docker image that receives the fully-resolved
19
20
20
21
Compose Bridge includes a default Kubernetes transformation using Go templates, which you can customize by replacing or extending templates.
21
22
22
-
### Syntax
23
+
### Template syntax
23
24
24
25
Compose Bridge makes use of templates to transform a Compose configuration file into Kubernetes manifests. Templates are plain text files that use the [Go templating syntax](https://pkg.go.dev/text/template). This enables the insertion of logic and data, making the templates dynamic and adaptable according to the Compose model.
25
26
@@ -43,9 +44,11 @@ key: value
43
44
{{ end }}
44
45
```
45
46
46
-
### Input
47
+
### Input model
47
48
48
-
You can generate the input model by running `docker compose config`. This canonical YAML output serves as the input for Compose Bridge transformations. Within the templates, data from the `compose.yaml` is accessed using dot notation, allowing you to navigate through nested data structures. For example, to access the deployment mode of a service, you would use `service.deploy.mode`:
49
+
You can generate the input model by running `docker compose config`.
50
+
51
+
This canonical YAML output serves as the input for Compose Bridge transformations. Within the templates, data from the `compose.yaml` is accessed using dot notation, allowing you to navigate through nested data structures. For example, to access the deployment mode of a service, you would use `service.deploy.mode`:
49
52
50
53
```yaml
51
54
# iterate over a yaml sequence
@@ -57,22 +60,24 @@ kind: DaemonSet
57
60
{{ end }}
58
61
```
59
62
60
-
You can check the [Compose Specification JSON schema](https://github.com/compose-spec/compose-go/blob/main/schema/compose-spec.json)to have a full overview of the Compose model. This schema outlines all possible configurations and their data types in the Compose model.
63
+
You can check the [Compose Specification JSON schema](https://github.com/compose-spec/compose-go/blob/main/schema/compose-spec.json)for a full overview of the Compose model. This schema outlines all possible configurations and their data types in the Compose model.
61
64
62
-
### Helpers
65
+
### Helper functions
63
66
64
67
As part of the Go templating syntax, Compose Bridge offers a set of YAML helper functions designed to manipulate data within the templates efficiently:
65
68
66
-
-`seconds`: Converts a [duration](/reference/compose-file/extension.md#specifying-durations) into an integer
67
-
-`uppercase`: Converts a string into upper case characters
68
-
-`title`: Converts a string by capitalizing the first letter of each word
69
-
-`safe`: Converts a string into a safe identifier, replacing all characters (except lowercase a-z) with `-`
70
-
-`truncate`: Removes the N first elements from a list
71
-
-`join`: Groups elements from a list into a single string, using a separator
72
-
-`base64`: Encodes a string as base64 used in Kubernetes for encoding secrets
73
-
-`map`: Transforms a value according to mappings expressed as `"value -> newValue"` strings
74
-
-`indent`: Writes string content indented by N spaces
75
-
-`helmValue`: Writes the string content as a template value in the final file
|`seconds`| Converts a [duration](/reference/compose-file/extension.md#specifying-durations) into an integer (seconds). |
72
+
|`uppercase`| Converts a string to uppercase. |
73
+
|`title`| Capitalizes the first letter of each word. |
74
+
|`safe`| Converts a string into a safe identifier (replaces non-lowercase characters with `-`). |
75
+
|`truncate`| Removes the first N elements from a list. |
76
+
|`join`| Joins list elements into a single string with a separator. |
77
+
|`base64`| Encodes a string as base64 (used for Kubernetes secrets). |
78
+
|`map`| Maps values using `“value -> newValue”` syntax. |
79
+
|`indent`| Indents string content by N spaces. |
80
+
|`helmValue`| Outputs a Helm-style template value. |
76
81
77
82
In the following example, the template checks if a healthcheck interval is specified for a service, applies the `seconds` function to convert this interval into seconds and assigns the value to the `periodSeconds` attribute.
78
83
@@ -82,7 +87,7 @@ In the following example, the template checks if a healthcheck interval is speci
82
87
{{ end }}
83
88
```
84
89
85
-
## Customization
90
+
## Customize the default templates
86
91
87
92
As Kubernetes is a versatile platform, there are many ways
88
93
to map Compose concepts into Kubernetes resource definitions. Compose
@@ -91,29 +96,51 @@ decisions and preferences, with varying level of flexibility and effort.
91
96
92
97
### Modify the default templates
93
98
94
-
You can extract templates used by the default transformation `docker/compose-bridge-kubernetes`,
95
-
by running `docker compose bridge transformations create --from docker/compose-bridge-kubernetes my-template`
96
-
and adjusting the templates to match your needs.
99
+
You can extract templates used by the default transformation `docker/compose-bridge-kubernetes`:
The templates are extracted into a directory named after your template name, in this case `my-template`. It includes:
106
+
107
+
- A Dockerfile that lets you create your own image to distribute your template
108
+
- A directory containing the templating files
109
+
110
+
Edit, [add](#add-your-own-templates), or remove templates as needed.
97
111
98
-
The templates are extracted into a directory named after your template name, in this case `my-template`.
99
-
It includes a Dockerfile that lets you create your own image to distribute your template, as well as a directory containing the templating files.
100
-
You are free to edit the existing files, delete them, or [add new ones](#add-your-own-templates) to subsequently generate Kubernetes manifests that meet your needs.
101
112
You can then use the generated Dockerfile to package your changes into a new transformation image, which you can then use with Compose Bridge:
102
113
103
114
```console
104
115
$ docker build --tag mycompany/transform --push .
105
116
```
106
117
107
-
You can then use your transformation as a replacement:
Copy file name to clipboardExpand all lines: content/manuals/compose/bridge/usage.md
+64-34Lines changed: 64 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,9 @@ keywords: docker compose bridge, compose kubernetes transform, kubernetes from c
8
8
9
9
{{< summary-bar feature_name="Compose bridge" >}}
10
10
11
-
Compose Bridge supplies an out-of-the-box transformation for your Compose configuration file. Based on an arbitrary `compose.yaml` file, Compose Bridge produces:
11
+
Compose Bridge includes a built-in transformation that automatically converts your Compose configuration into a set of Kubernetes manifests.
12
+
13
+
Based on your `compose.yaml` file, it produces:
12
14
13
15
- A [Namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) so all your resources are isolated and don't conflict with resources from other deployments.
14
16
- A [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) with an entry for each and every [config](/reference/compose-file/configs.md) resource in your Compose application.
@@ -22,61 +24,74 @@ Compose Bridge supplies an out-of-the-box transformation for your Compose config
22
24
It also supplies a Kustomize overlay dedicated to Docker Desktop with:
23
25
-`Loadbalancer` for services which need to expose ports on host.
24
26
- A `PersistentVolumeClaim` to use the Docker Desktop storage provisioner `desktop-storage-provisioner` to handle volume provisioning more effectively.
25
-
- A Kustomize file to link all the resources together.
27
+
- A `Kustomization.yaml` file to link all the resources together.
28
+
29
+
If your Compose file defines a `models` section for a service, Compose Bridge automatically configures your deployment so your service can locate and use its models via Docker Model Runner.
30
+
31
+
For each declared model, the transformation injects two environment variables:
32
+
33
+
-`<MODELNAME>_URL`: The endpoint for Docker Model Runner serving that model
34
+
-`<MODELNAME>_MODEL`: The model’s name or identifier
35
+
36
+
You can optionally customize these variable names using `endpoint_var` and `model_var`.
37
+
38
+
The default transformation generates two different overlays - one for Docker Desktop whilst using a local instance of Docker Model Runner, and a `model-runner` overlay with all the relevant Kubernetes resources to deploy Docker Model Runner in a pod.
For more details, see [Use Model Runner](use-model-runner.md).
26
47
27
48
## Use the default Compose Bridge transformation
28
49
29
-
To use the default transformation run the following command:
50
+
To convert your Compose file using the default transformation:
30
51
31
52
```console
32
53
$ docker compose bridge convert
33
54
```
34
55
35
-
Compose looks for a `compose.yaml` file inside the current directory and then converts it.
56
+
Compose looks for a `compose.yaml` file inside the current directory and generates Kubernetes manifests.
36
57
37
-
When successful, Compose Bridge generates Kubernetes manifests and logs output similar to the following:
58
+
Example output:
38
59
39
60
```console
40
-
$ docker compose bridge convert -f compose.yaml
41
-
Kubernetes resource api-deployment.yaml created
42
-
Kubernetes resource db-deployment.yaml created
43
-
Kubernetes resource web-deployment.yaml created
44
-
Kubernetes resource api-expose.yaml created
45
-
Kubernetes resource db-expose.yaml created
46
-
Kubernetes resource web-expose.yaml created
47
-
Kubernetes resource 0-avatars-namespace.yaml created
61
+
$ docker compose -f compose.yaml bridge convert
62
+
Kubernetes resource backend-deployment.yaml created
63
+
Kubernetes resource frontend-deployment.yaml created
64
+
Kubernetes resource backend-expose.yaml created
65
+
Kubernetes resource frontend-expose.yaml created
66
+
Kubernetes resource 0-my-project-namespace.yaml created
48
67
Kubernetes resource default-network-policy.yaml created
49
-
Kubernetes resource private-network-policy.yaml created
50
-
Kubernetes resource public-network-policy.yaml created
51
-
Kubernetes resource db-db_data-persistentVolumeClaim.yaml created
52
-
Kubernetes resource api-service.yaml created
53
-
Kubernetes resource web-service.yaml created
68
+
Kubernetes resource backend-service.yaml created
69
+
Kubernetes resource frontend-service.yaml created
54
70
Kubernetes resource kustomization.yaml created
55
-
Kubernetes resource db-db_data-persistentVolumeClaim.yaml created
56
-
Kubernetes resource api-service.yaml created
57
-
Kubernetes resource web-service.yaml created
71
+
Kubernetes resource backend-deployment.yaml created
72
+
Kubernetes resource frontend-deployment.yaml created
73
+
Kubernetes resource backend-service.yaml created
74
+
Kubernetes resource frontend-service.yaml created
75
+
Kubernetes resource kustomization.yaml created
76
+
Kubernetes resource model-runner-configmap.yaml created
77
+
Kubernetes resource model-runner-deployment.yaml created
78
+
Kubernetes resource model-runner-service.yaml created
79
+
Kubernetes resource model-runner-volume-claim.yaml created
58
80
Kubernetes resource kustomization.yaml created
59
81
```
60
82
61
-
These files are then stored within your project in the `/out`folder.
83
+
All generated files are stored in the `/out`directory in your project.
62
84
63
-
The Kubernetes manifests can then be used to run the application on Kubernetes using
64
-
the standard deployment command `kubectl apply -k out/overlays/desktop/`.
85
+
## Deploy the generated manifests
65
86
66
87
> [!IMPORTANT]
67
88
>
68
-
> Make sure you have enabled Kubernetes in Docker Desktop before you deploy your Compose Bridge transformations.
89
+
> Before you deploy your Compose Bridge transformations, make sure you have [enabled Kubernetes](/manuals/desktop/settings-and-maintenance/settings.md#kubernetes) in Docker Desktop.
69
90
70
-
If you want to convert a `compose.yaml` file that is located in another directory, you can run:
91
+
Once the manifests are generated, deploy them to your local Kubernetes cluster:
> Make sure you are signed in to your Docker account, navigate to your container in the **Containers** view, and in the top-right corner select **View configurations** and then **Convert and Deploy to Kubernetes**.
87
102
103
+
## Additional commands
104
+
105
+
Convert a `compose.yaml` file located in another directory:
0 commit comments