ANN Technologies Logo
ANN Technologies brand mark ANN Technologies Find your spark

Containerising Legacy Applications: A Step-by-Step Guide

Move legacy applications to containers without a full rewrite. Learn the lift-and-shift approach, volume management, and health check configuration.

Why Containerise Legacy Applications?

Legacy applications running on bare-metal servers or old VMs are expensive to maintain, difficult to scale, and create operational risk. Containerisation packages them with all dependencies into portable, reproducible units that run consistently across any environment.

Step 1: Analyse the Application

Before writing a Dockerfile, document your application’s dependencies: runtime versions, environment variables, port bindings, file system requirements, and external service connections. This analysis prevents surprises during containerisation.

Step 2: Write a Production Dockerfile

# Multi-stage build for a legacy Node.js app
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

FROM node:18-alpine AS runtime
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY . .
EXPOSE 3000
HEALTHCHECK --interval=30s CMD wget -qO- http://localhost:3000/health
CMD ["node", "server.js"]

Step 3: Handle Persistent Storage

Legacy apps often write files to the local filesystem. Mount Docker volumes for any data that must persist beyond the container lifecycle — logs, uploads, and configuration files.