Five Challenges with Developing Locally Using Docker Compose

After the popularization of containers, a lot of the development workflow started leaning on Docker Compose. Developers would have a Docker Compose file which defined how to build the container images for all their services, what ports to expose, and have volumes attached to their containers. They would then run the containers locally and leverage the attached volumes to develop their application. However, there are a lot of limitations in this flow which not only hamper developer productivity but can also cause security issues and bugs. Let's discuss some of these and see how using Okteto you can fix these problems.
Running Things Locally Isn't Practical for Modern Development
When dealing with just a couple of containers running simple microservices, developers might not encounter any issues. However, as they scale up the number of microservices or run more demanding workloads, even the most powerful development machine will start experiencing bottlenecks. This is especially true for modern cloud-native applications we develop today. They typically consist of 10 to 50 different microservices, which is impractical to run locally. Not only does it slow down development, but restarting or spinning up everything again severely hampers productivity.
This is Not How You Run Containers in Production
One significant issue is that running containers with Docker Compose on local machines differs from how it's done in production. Instead of directly running containers, production environments leverage Kubernetes resources like Deployments or StatefulSets. Consequently, developing locally with Docker Compose means working in an environment that deviates from production. This discrepancy increases the likelihood of bugs that are difficult to identify, such as misspelt environment variables or other similar issues. To ensure stability and avoid unexpected surprises upon deployment, it is crucial to develop in a realistic environment.
Environments Aren't Reproducible
When developers launch their application using docker compose up, they cannot launch another instance of the application to experiment or try out a different version or commit. Technically, they could rename things and then run them again, but not only is that inconvenient, it also significantly impacts the performance of the local machine. Consequently, the developer's creativity and freedom become restricted.
Coding Agents Need Their Own Copy
Coding agents make the first three problems worse. A developer who runs several agents needs each of them to start the application to try its changes, and all of them compete for the same laptop: the same ports, the same CPU and memory. In practice, the agents take turns, or they skip running the application and hand over changes that nobody has tried.
End to End Tests
While Docker Compose is useful for bringing up all the services of your application locally, it doesn't replicate the realistic environment of production. As a result, running end-to-end tests on your application using Docker Compose may not yield the expected results.
How Okteto Fixes These Problems and Improves the Docker Compose Workflow
Okteto takes your Docker Compose application and translates your application services into Kubernetes resources, deploying them on a cluster. This ensures that developers can begin development in an environment that closely resembles production. Additionally, by not running any containers locally, the local machine's resources are not constrained, regardless of the demands of the application. What's even better is that developers can deploy their application, or different versions of it, to different Okteto Namespaces, allowing for multiple copies. This approach treats each environment as ephemeral, enabling them to quickly spin up new instances as needed.
Each environment also gets its own endpoints instead of localhost, so you can run realistic end-to-end tests against it. And because every environment lives in its own Namespace, each developer and each coding agent gets a separate copy of the application without sharing a laptop.
Next Steps
The Docker Compose on Kubernetes tutorial deploys a Compose application with Okteto step by step.
Subscribe to our newsletter
What we learn running development environments and coding agents on Kubernetes, in your inbox.
About Okteto
Okteto gives every developer, coding agent and pull request an on-demand environment on your Kubernetes.
