Use the default Compose Bridge transformation
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:
- A Namespace so all your resources are isolated and don't conflict with resources from other deployments.
- A ConfigMap with an entry for each and every config resource in your Compose application.
- Deployments for application services. This ensures that the specified number of instances of your application are maintained in the Kubernetes cluster.
- Services for ports exposed by your services, used for service-to-service communication.
- Services for ports published by your services, with type
LoadBalancerso that Docker Desktop will also expose the same port on the host. - Network policies to replicate the networking topology defined in your
compose.yamlfile. - PersistentVolumeClaims for your volumes, using
hostpathstorage class so that Docker Desktop manages volume creation. - Secrets with your secret encoded. This is designed for local use in a testing environment.
It also supplies a Kustomize overlay dedicated to Docker Desktop with:
Loadbalancerfor services which need to expose ports on host.- A
PersistentVolumeClaimto use the Docker Desktop storage provisionerdesktop-storage-provisionerto handle volume provisioning more effectively. - A
Kustomization.yamlfile 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 identifier
You 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.
Use the default Compose Bridge transformation
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.
Deploy the generated manifests
重要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/
情報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.
Additional commands
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