Moving from Docker Compose to Kubernetes: What Maps Cleanly and What Needs Thought
How compose services, ports, environment, volumes and health checks map to Kubernetes objects, the settings with no equivalent, and a safe conversion path.

Docker Compose is how most teams run a multi-container app on one machine. Kubernetes is where many of them end up when they need several machines, rolling updates and self-healing. The good news is that most of a compose file has a direct Kubernetes counterpart. The bad news is that the parts that do not map are exactly the ones that cause outages if nobody looks at them.
The basic mapping
A compose service becomes a Deployment: a template for identical pods with a replica count, the image, command, environment and resources. deploy.replicas becomes replicas. The compose entrypoint becomes the container's command, and the compose command becomes args, which is easy to get backwards.
Ports become a Service. In compose, other containers reach a service by its name on the shared network. In Kubernetes, a Service with the same name gives the same result: the web container can still connect to db:5432. Published ports such as 8080:3000 become a Service port of 8080 forwarding to container port 3000. Reaching the app from outside the cluster is a separate decision: an Ingress for HTTP, a LoadBalancer on a cloud provider, or port-forwarding during development.
Configuration and secrets
Environment variables can stay inline in the Deployment, but it is cleaner to put them in a ConfigMap and load them with envFrom. Anything sensitive, such as database passwords, API tokens and signing keys, belongs in a Secret instead. Secrets are only base64-encoded by default, so keep the real values out of Git with a tool such as sealed-secrets or SOPS, or use your cloud's secret manager.
Compose files often use variables like ${DB_PASSWORD:-changeme}. Resolve them from your .env file before converting, and check that no default placeholder password survives into production.
Volumes: the part that needs care
Named volumes map naturally to PersistentVolumeClaims, which ask the cluster for storage of a given size and storage class. A volume with the usual ReadWriteOnce access mode can only be mounted on one node at a time, so a Deployment using it should run a single replica with the Recreate strategy, or become a StatefulSet. Several replicas writing to one database volume is a recipe for corruption.
Bind mounts like ./init.sql:/docker-entrypoint-initdb.d/init.sql have no equivalent: the path exists on your laptop, not on cluster nodes. Configuration files become ConfigMaps mounted at the same path; data becomes a claim.
Health, resources and start order
Compose health checks translate to liveness and readiness probes. Readiness matters most: it keeps traffic away from a pod until it can serve. Resource limits in compose, such as cpus 0.5 and memory 512M, become limits of 500m CPU and 512Mi memory, and you should set requests too, so the scheduler knows how much room a pod needs.
depends_on has no counterpart. Pods start in any order and restart independently, so your app must retry its database connection, or use an init container that waits. That is healthier anyway, because dependencies also restart in production.
Converting without losing anything
The Docker Compose to Kubernetes Converter does the mechanical part in your browser. Paste a compose file, optionally your .env, and choose a namespace, the Service type for published ports, an Ingress host, the volume size and storage class. You get ConfigMaps, Secrets, PersistentVolumeClaims, Services and Deployments as YAML, as one file or one file per resource.
The part that matters most is the review checklist next to the YAML. It lists every decision a human still has to make: images that only exist as a build context, placeholder secrets, bind mounts, services without limits or probes, privileged containers, latest tags and shared volumes with several replicas. Each item says what to do next.
A safe rollout
Work through the checklist, then validate the YAML against your cluster with kubectl apply --dry-run=server, which catches schema and admission errors without changing anything. Apply to a test namespace first, check logs and readiness, and only then move real traffic. Once it runs, consider packaging the manifests with Kustomize or Helm so differences between environments stay manageable.
Summary
Services become Deployments and Services, environment becomes ConfigMaps and Secrets, named volumes become claims and health checks become probes. Bind mounts, start order, shared volumes and secrets need real decisions. Convert automatically, then spend your time on the checklist rather than on retyping YAML.



