What is containerization? Containerized apps explained
What is containerization and how do containerized applications work? Containers vs VMs, benefits, trade-offs, and how to containerize an app step by step.
Docker · · 7 min read
The app runs on your laptop and fails on the server. The server has a different Python version, a missing system library, or an OPENSSL build that disagrees with your dependency. You fix it by hand, and six months later nobody remembers how. Containerization exists to end that cycle: you package the app with everything it needs to run, and the package behaves the same on any host with a container runtime. This guide explains what containerization is, how containerized applications work underneath, when they are worth it, and how to containerize an existing app.
What is containerization?
Containerization is packaging an application together with its runtime, libraries and configuration into a container image, then running that image as an isolated process on a shared operating system kernel.
Two ideas carry the whole concept:
- The image is the unit of delivery. You build it once and ship the same artifact to every environment.
- The container is an isolated process, not a machine. It shares the host's kernel and gets its own view of the filesystem, network and process tree.
A containerized application is any application delivered and run this way. It can be a single web service, a database, or one of fifty microservices.
How containers work under the hood
Containers are built from Linux kernel features that predate Docker by years:
- Namespaces give a process its own view of process IDs, network interfaces, mount points, hostname and users. Inside the container, the app is PID 1 and sees only its own files.
- cgroups (control groups) limit and account for CPU, memory, disk I/O and process count.
- Union filesystems such as OverlayFS stack read-only image layers with one writable layer on top.
- Security filters such as seccomp profiles and dropped Linux capabilities reduce what the process may ask the kernel to do.
The Open Container Initiative (OCI) standardises the image format and the runtime interface, so an image built with Docker runs on Podman, containerd or Kubernetes. If you want the image and container distinction in detail, see Docker image vs container.
Containers vs virtual machines
| Containers | Virtual machines | |
|---|---|---|
| Isolation boundary | Process, sharing the host kernel | Full guest OS on a hypervisor |
| Start time | Milliseconds to seconds | Tens of seconds to minutes |
| Size | Megabytes to a few hundred MB | Gigabytes |
| Density per host | Dozens to hundreds | A handful to dozens |
| Kernel | The host's | Its own, any OS |
| Isolation strength | Good, weaker than a VM | Strong, hardware-assisted |
| Best for | Packaging and running apps | Running different OSes, hard multi-tenant isolation |
They are not rivals. Most containers in production run inside VMs: your cloud server is a VM, and Docker runs on it. The VM isolates you from other customers. Containers isolate your apps from each other and make them portable.
Benefits of containerized applications
- Consistency. The same image runs in development, CI, staging and production. "Works on my machine" turns into "works in this image".
- Fast, repeatable deploys. Shipping a new version means starting containers from a new image, which takes seconds.
- Cheap rollbacks. The previous image still exists. Rolling back means running it again.
- Density. Many isolated services fit on one server without one VM per app.
- Clear dependencies. The Dockerfile records exactly what the app needs, in version control.
- Portability. Any host with an OCI runtime can run the image, from a laptop to a managed cloud service.
The trade-offs nobody should skip
Containerization adds its own work:
- State needs a plan. Containers are disposable. Databases and uploads must live on volumes, and those need backups. See Docker volumes.
- Networking is different.
localhostmeans the container, and published ports interact with your firewall in surprising ways. See Docker networking. - Images can carry vulnerabilities. Base images age. You need to rebuild and scan them on a schedule.
- Weaker isolation than VMs. A kernel bug affects every container on the host. Running untrusted code needs extra layers such as gVisor, Kata Containers or separate VMs.
- More moving parts. A registry, a build pipeline, a proxy and often an orchestrator join the stack.
For a single PHP site on shared hosting, this can be more than you need. For anything with several services, frequent deploys or more than one environment, it usually pays off.
How to containerize an application, step by step
Take a typical Node.js web app.
1. Make the app container-friendly
Containers work best with apps that follow a few rules:
- Read configuration from environment variables, not from files edited on the server.
- Log to stdout and stderr, not to files.
- Listen on
0.0.0.0, not127.0.0.1, so traffic from outside the container reaches it. - Keep no state on local disk, or write it to one known directory that becomes a volume.
- Shut down cleanly on
SIGTERM.
2. Write a Dockerfile
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build && npm prune --omit=dev
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]
The multi-stage build keeps compilers and dev dependencies out of the final image. USER node runs the app without root.
3. Add a .dockerignore
node_modules
.git
.env
dist
This keeps secrets and local build output out of the build context.
4. Build and run it locally
docker build -t my-app:0.1.0 .
docker run --rm -p 3000:3000 -e DATABASE_URL=postgres://... my-app:0.1.0
5. Add the other services
If the app needs a database or cache, describe them in a compose file so the whole stack starts with one command. Our guides on what is Docker Compose and Dockerfile vs Docker Compose cover that step.
6. Push to a registry and deploy
Tag each build with a version you never reuse, push it to a registry, and deploy that exact tag. Never deploy :latest to production.
Containerization and orchestration
Running five containers on one server is manageable by hand. Running fifty across several servers needs an orchestrator: software that places containers on nodes, restarts them when they fail, rolls out updates and routes traffic. The main options are Docker Swarm, which ships with Docker and reads compose-format files, and Kubernetes, which is far more extensible and far more to operate. Our Docker Swarm vs Kubernetes comparison helps you choose.
Common use cases
- Web apps and APIs that deploy many times a day.
- Microservices, where each team ships its own image on its own schedule.
- Self-hosting open-source software, which is now almost always distributed as images and compose files.
- CI pipelines, where each job runs in a clean, known environment.
- Development environments that match production closely.
- Batch and scheduled jobs, which start, run and disappear.
Where a PaaS fits
Containerization gives you an image. Something still has to build it, store it, run it, put it behind HTTPS, collect its logs, back up its data and roll it back. A platform as a service does that around your containers. LogiStack, the open-source PaaS we build, runs containerized apps on Docker Swarm with Caddy in front:
- It builds from your Dockerfile, or with Railpack when you have no Dockerfile at all, in rootless BuildKit. See build types.
- Each build is tagged with its deployment ID, so a rollback runs exactly the earlier image.
- New containers pass their health check before old ones stop.
- It scans each running image for known vulnerabilities after every deploy and once a day.
- Any published OCI image runs too, from Docker Hub, GHCR or your own registry.
It is fair to say what it is not: a young project with a smaller community, built on Swarm rather than Kubernetes. If your organisation already standardised on Kubernetes, a Kubernetes-native platform fits better.
FAQ
Is containerization the same as Docker?
No. Docker is the tool that made containerization popular, but containers are a Linux kernel capability and the image format is an open OCI standard. Podman, containerd and CRI-O run the same images. See alternatives to Docker.
Is containerization the same as virtualization?
Both isolate workloads, at different levels. Virtualization emulates hardware and runs a full guest OS. Containerization isolates processes on one shared kernel. Containers are lighter and faster; VMs isolate more strongly.
Do containerized applications have to be microservices?
No. A monolith in one container gets the same benefits of consistent builds, fast deploys and easy rollbacks. Many teams containerize a monolith first and split it later, if ever.
Can Windows apps be containerized?
Yes, with Windows containers on Windows Server hosts, but they need a Windows kernel and are a separate ecosystem from Linux containers. Most server workloads, and nearly all self-hosted software, use Linux containers.
Are containers secure?
They are reasonably secure when you run as a non-root user, drop capabilities, keep images patched and never mount the Docker socket into untrusted containers. They are not a hard boundary for hostile code. Scan images and rebuild them when their base image gets a fix.
If your app already has a Dockerfile, the hard part of containerization is done. Install LogiStack on a server, connect the repository, and every push becomes a pinned, scanned image with a rollback path.