content/manuals/compose/bridge/usage.md
{{< summary-bar feature_name="Compose bridge" >}}
Compose Bridge includes a built-in transformation that automatically converts your Compose configuration into a set of Kubernetes manifests.
Based on your compose.yaml file, it produces:
LoadBalancer so that Docker Desktop will also expose the same port on the host.compose.yaml file.hostpath storage class so that Docker Desktop manages volume creation.It also supplies a Kustomize overlay dedicated to Docker Desktop with:
Loadbalancer for services which need to expose ports on host.PersistentVolumeClaim to use the Docker Desktop storage provisioner desktop-storage-provisioner to handle volume provisioning more effectively.Kustomization.yaml file to link all the resources together.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.
For each declared model, the transformation injects two environment variables:
<MODELNAME>_URL: The endpoint for Docker Model Runner serving that model<MODELNAME>_MODEL: The model’s name or identifierYou can optionally customize these variable names using endpoint_var and model_var.
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.
| Environment | Endpoint |
|---|---|
| Docker Desktop | http://host.docker.internal:12434/engines/v1/ |
| Kubernetes | http://model-runner/engines/v1/ |
For more details, see Use Model Runner.
To convert your Compose file using the default transformation:
$ docker compose bridge convert
Compose looks for a compose.yaml file inside the current directory and generates Kubernetes manifests.
Example output:
$ docker compose -f compose.yaml bridge convert
Kubernetes resource backend-deployment.yaml created
Kubernetes resource frontend-deployment.yaml created
Kubernetes resource backend-expose.yaml created
Kubernetes resource frontend-expose.yaml created
Kubernetes resource 0-my-project-namespace.yaml created
Kubernetes resource default-network-policy.yaml created
Kubernetes resource backend-service.yaml created
Kubernetes resource frontend-service.yaml created
Kubernetes resource kustomization.yaml created
Kubernetes resource backend-deployment.yaml created
Kubernetes resource frontend-deployment.yaml created
Kubernetes resource backend-service.yaml created
Kubernetes resource frontend-service.yaml created
Kubernetes resource kustomization.yaml created
Kubernetes resource model-runner-configmap.yaml created
Kubernetes resource model-runner-deployment.yaml created
Kubernetes resource model-runner-service.yaml created
Kubernetes resource model-runner-volume-claim.yaml created
Kubernetes resource kustomization.yaml created
All generated files are stored in the /out directory in your project.
[!IMPORTANT]
Before you deploy your Compose Bridge transformations, make sure you have enabled Kubernetes in Docker Desktop.
Once the manifests are generated, deploy them to your local Kubernetes cluster:
$ kubectl apply -k out/overlays/desktop/
[!TIP]
You can convert and deploy your Compose project to a Kubernetes cluster from the Compose file viewer.
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.
Convert a compose.yaml file located in another directory:
$ docker compose -f <path-to-file>/compose.yaml bridge convert
To see all available flags, run:
$ docker compose bridge convert --help