Containers Are Not Architecture
Docker makes system boundaries visible and portable – you still have to draw them by hand, and a monolith remains a monolith inside a container.
Containers Are Not Architecture
A badly cut monolith doesn’t get better when you put it in a container. It stays the same monolith – the same tangled dependencies, the same shared database, the same deployment where everything goes out at once. The only new thing is the Dockerfile on top. Still, the same equation is being heard everywhere right now, at conferences as well as in project meetings: we’re introducing Docker, so now we’re doing microservices. At first, the one has nothing to do with the other. Docker packages software. It doesn’t design it.
The mix-up isn’t a coincidence, and it isn’t stupid either. It has a reason, and that reason is worth a look – just like the question of what containers actually do. Because that’s quite a lot. It’s just something other than architecture.
Why the equation works so well#
Both topics grew big at the same time. Docker is at version 1.6, 1.7 is in the works, DockerCon in San Francisco starts in a week and a half, and after the months-long public dispute between Docker and CoreOS over the “right” container format, an initiative for an open, vendor-neutral standard is taking shape right now. Orchestration is a jungle: Mesos on one side, Docker’s own Swarm on the other, and Google is working on Kubernetes, which hasn’t reached version 1.0 yet. At the same time, the text by James Lewis and Martin Fowler about microservices has been the reference point of every architecture discussion for a good year.
Both waves carry the same vocabulary before them: small, independent units, isolated, individually deployable. But if you put the texts side by side, you see the gap immediately. Lewis and Fowler talk about domain boundaries, about teams, about data ownership. The Docker documentation talks about images, layers and processes. That a container is an “independent unit” holds true for the process and its file system – not for the domain logic inside it. A container doesn’t know whether a cleanly cut service runs inside it or a mountain of twelve years of organically grown code. It doesn’t care either.
The equation works because it’s convenient. You can write a Dockerfile in an afternoon. You don’t get a module split that two teams no longer argue about in an afternoon – that takes weeks of conversations about data, responsibilities and interfaces, and at the end there is no tool to show off, just a system that is easier to change. When both sail under the same buzzword, the afternoon wins. After all, only one of the two is something you can show off.
What a container really does#
At the beginning of the year, I packaged a small .NET API in a container: Nancy as the web framework, self-hosted, LiteDB as a file database, the whole thing on Mono so it runs on Linux. Not a customer project, an experiment – I wanted to know whether the path from Windows-centric .NET code to a Linux container can be walked without major contortions. It can. The Dockerfile was sobering in how unspectacular it was:
FROM mono:3.12
COPY . /app
WORKDIR /app
RUN nuget restore shop-api.sln && \
xbuild /p:Configuration=Release shop-api.sln
EXPOSE 8080
CMD ["mono", "src/ShopApi/bin/Release/ShopApi.exe"]
Exactly this lack of spectacle is the point. Everything the service needs to run is in thirteen lines: the runtime including its version, the build path, the port, the one command that starts the process. Before, this knowledge was scattered across a wiki page (“Set up the development environment, 14 steps”), the heads of two colleagues and the configuration of a build server that nobody wanted to touch anymore. Now it’s in the repository, versioned with the code and read in reviews.
That’s the honest benefit of containers, and it’s considerable:
- The same environment on the laptop, in CI and on the server – “works on my machine” loses its terror.
- An explicit entry point: exactly one command starts the process, and nothing depends on a logged-in user or a terminal session.
- Dependencies live in the image instead of the wiki – if you want to know what the service needs, you read the Dockerfile, not the memory of the most senior colleague.
- An artifact that can be moved unchanged from environment to environment instead of being rebuilt on every machine.
Note what doesn’t appear in this list: domain boundaries, data ownership, independent releases. The Dockerfile above doesn’t reveal whether ShopApi.exe is a focused service or a colossus. It builds both without complaint.
The monolith just moves house#
How little the packaging changes the content becomes clear as soon as you containerize a real monolith. Let’s take a shop of the kind that exists countless times: orders, invoices and catalog in one solution, a shared database, one deployment. With Docker Compose, the local environment for it is quickly described:
shop-api:
build: .
ports:
- "8080:8080"
links:
- shop-db
shop-db:
image: postgres:9.4
environment:
POSTGRES_DB: shop
This file is useful – everyone on the team starts the current state with one command. But above all, it’s one thing: honest. It documents in black and white that there is exactly one deployable unit and one database that all parts write into. If you change a line in the billing code, you still build and deploy the entire shop. If you migrate the order schema, you still hold your breath, because the catalog sits on the same tables. The release cadence, the coupling, the fear of the migration – all unchanged.
flowchart LR
subgraph before["Before"]
M1["Monolith<br/>Orders + Billing + Catalog"] --> D1[("one database")]
end
subgraph after["After – with Docker"]
M2["Container<br/>Monolith<br/>Orders + Billing + Catalog"] --> D2[("one database")]
end
before -. "docker build" .-> afterThe diagram is deliberately boring. The same system stands on the left and on the right. The container has made the structure visible and portable – it hasn’t created a new one. And visibility is no small thing. But it’s often confused with change, the way a moving box is confused with tidying up. Only when you pack it do you see what has piled up. Nothing has been thrown away yet.
Making boundaries visible isn’t drawing boundaries#
The actual work is called the module split, and it happens before any Dockerfile. Three questions decide whether a split holds. Who owns which data – who may change the order tables, and who only gets to see them through an interface? What does the contract between the parts look like – which calls are allowed, and how stable do they stay when something changes inside? And: what can be shipped independently without two teams having to align their calendars?
None of this needs Docker. A clean split can be drawn in the middle of the monolith, in the same solution, in the same process. Between the orders module and the billing module there is then a deliberately narrow contract:
// the only allowed path from Orders into Billing –
// no shared tables, no reaching into internals
public interface IBillingService
{
Invoice CreateInvoice(OrderId orderId, Money total);
}
The more uncomfortable half belongs to it as well: Orders writes exclusively into its own tables, Billing into its own. No join across the module boundary, not even “just for the report.” Once this discipline has held for a while, the rest is mechanics. Then – and only then – the module becomes its own container if needed, and the Compose file suddenly looks like what Lewis and Fowler describe:
orders:
build: ./orders
ports:
- "8080:8080"
links:
- orders-db
- billing
orders-db:
image: postgres:9.4
billing:
build: ./billing
links:
- billing-db
billing-db:
image: postgres:9.4
The crux: this file is the result of the design work, not a replacement for it. If you write it down without having carried out the split in the code and in the data first, you get two containers reaching into each other’s database – the same monolith, now with network latency in between. That’s the most expensive variant of a monolith I know: distributed but not decoupled. Every orchestration tool, whether Mesos, Swarm or soon Kubernetes, only multiplies this state. It distributes what you give it. If you give it a tangled split, it distributes tangles.
flowchart LR
subgraph om["Orders module"]
O["orders"] --> ODB[("orders-db")]
end
subgraph bm["Billing module"]
B["billing"] --> BDB[("billing-db")]
end
O -- "Contract:<br/>CreateInvoice(orderId, total)" --> BThis picture is the difference. The boxes aren’t what’s interesting, but the arrows that are missing: no arrow from orders to billing-db, no back channel bypassing the interface. No tool draws these missing arrows for you. You have to earn them, against the resistance of day-to-day business, which always has a good reason for that one small shortcut.
The container as a touchstone#
If containers help with design at all, then as a touchstone. In the Mono experiment, I noticed that the most unpleasant question wasn’t “How do I build the image?” but “What goes into it?” The service pulled configuration from three sources, expected a network drive and wrote logs to a hard-wired path. None of this had been a problem before, because the machine it ran on silently provided all of it. The container provides nothing silently. It forces you to either write every assumption into the image or bring it to the surface as an environment variable. Each of these assumptions was essentially an invisible coupling – to a machine, to a department, to a piece of operations folklore that was written down nowhere.
That’s the same kind of pressure a good module split exerts, just one level deeper. If you can’t say for a service what belongs in its image and what comes from outside, you don’t know the boundaries of that service – and shouldn’t be talking about microservices yet. In that sense, containerizing the monolith is a perfectly good first step: not because it’s architecture, but because it forces the inventory without which no later split succeeds. You learn more about your system along the way than you’d like.
You should just treat the step as what it is. A containerized monolith is a completely legitimate state – built reproducibly, started the same way everywhere, with documented dependencies. For many systems, that’s enough for years to come. If, on the other hand, you sell it as “microservices migration, phase one,” you have put a promise out into the world that the packaging can’t keep.
What I take away from this#
For me, an order has emerged that holds up in discussions: first containerize the monolith and take the operational benefits – the same environment everywhere, an explicit process entry point, dependencies in the image. In parallel, draw the boundaries in the code where they cost nothing: modules, separate tables, narrow contracts like the IBillingService example above. And only when a boundary has stayed stable over several releases and there is a concrete reason – a different release cadence, a different load, a different team – does the module become its own service with its own container.
Along this path, Docker does two things excellently: it transports the units you have cut, and it ruthlessly exposes where you haven’t cut at all yet. Both are valuable. Neither of them is design. The standardization now emerging around the container format will make packaging even more of a given – which makes it all the more important not to confuse it with the content. A Dockerfile answers the question of how a process starts. If you want to answer the question of where one system ends and the next begins, you’re still sitting in front of a whiteboard, not a YAML file.
Further reading#
- MikeBild/dotnet-docker on GitHub – the experiment mentioned above: Nancy, self-hosting and LiteDB on Mono in a container
- Microservices – James Lewis and Martin Fowler – the reference text on domain boundaries, data ownership and independent delivery
- Dockerfile reference – the official description of all build instructions
- Docker Compose documentation – basics of describing several services in one file
Revised and translated from German with the help of AI.