TechOps Examples
Hey — It's Govardhana MK 👋
Welcome to another technical edition.
Every Tuesday – You’ll receive a free edition with a byte-size use case, remote job opportunities, top news, tools, and articles.
Every Thursday and Saturday – You’ll receive a special edition with a deep dive use case, remote job opportunities and articles.
Top engineers at Anthropic and OpenAI say AI now writes 100% of their code.
If you're not using AI, you're spending 40 hours doing what they do in 4.
These 100+ Claude Code hacks fix that and help you ship 10x faster.
Sign up for The Code and get:
100+ Claude Code hacks used by top engineers — free
The Code newsletter — learn the latest AI tools, tips, and skills to code faster with AI in 5 minutes a day
🧠 USE CASE
Dockerfile vs. Docker Compose: What You Should Know
When working with Docker, you'll often encounter two important concepts: Dockerfile and Docker Compose.
Although they are complementary, they serve different purposes in your containerized environment.
Dockerfile: Used to create and build Docker images.
Docker Compose: Used to run Docker containers as part of a multi-container setup or with specific runtime configs.

Dockerfile Overview
A Dockerfile is a script with instructions to build a Docker image, defining the base image, copying files, installing dependencies, and setting environment configurations.
Key Features:
Image Creation: Dockerfile builds images layer by layer.
Customizability: It defines dependencies, environment variables, and installations.
Efficiency: Supports build caching for faster image creation.
Version Control: Allows versioned images for different environments.
Consistency: By specifying every detail, ensures consistent builds across environments.
Here's an example Dockerfile that builds a Node.js app:
FROM node:16-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]
This Dockerfile performs the following:
Uses Node.js 16 on an Alpine base for a smaller image size.
Sets
/usr/src/appas the working directory.Copies the
package.jsonand installs the necessary dependencies.Copies the application files.
Runs the
npm startcommand to launch the application.
Command to Build the Image:
docker build -t techops-node-app .
Output:
Running the command builds the image and tags it as techops-node-app.
Sending build context to Docker daemon 4.096kB
Step 1/4 : FROM node:16-alpine
...
Successfully built 456abc123
Successfully tagged techops-node-app:latest
Docker Compose Overview
Docker Compose defines and runs multi-container applications using a YAML file to configure services, networks, and volumes, managing container interactions.
Since version 1.28.6, Docker Compose defaults to compose.yaml or compose.yml, with backward compatibility for docker-compose.yaml/yml. If both exist, compose.yaml is preferred.
Key Features:
Orchestration: Manages container communication, data sharing, and networking.
Multi-Container Support: Simplifies managing multiple services.
Declarative Configuration: Uses YAML for easy service setup.
Resource Limiting: Sets memory and CPU limits for services.
Network Management: Handles service networking automatically.
Volume Management: Manages shared or persistent data.
Let’s configure a a Node.js service and a PostgreSQL database as an example:
version: '3.9'
services:
app:
build: .
ports:
- "4000:4000"
environment:
NODE_ENV: production
deploy:
resources:
limits:
cpus: "1.0"
memory: "1G"
volumes:
- .:/usr/src/app
networks:
- app-net
db:
image: postgres:13
environment:
POSTGRES_DB: techopsdb
volumes:
- db-data:/var/lib/postgresql/data
networks:
- app-net
networks:
app-net:
volumes:
db-data:
Running and Managing the Application
To build and run the services defined in the compose.yaml file, use the following command: docker compose up
Example Output:
Creating network "techops-app-net" with the default driver
Creating volume "techops-db-data" with default driver
Building app
Creating techops_app_1 ... done
Creating techops_db_1 ... done
Attaching to techops_app_1, techops_db_1
app_1 | Application running on port 4000...
db_1 | PostgreSQL init process complete; ready for startup.
Now, the app runs on port 4000, with PostgreSQL internally on the app-net network, allowing service communication.
In summary, Dockerfile builds the image, while Docker Compose manages multiple containers.
Knowing both is crucial, whether you're running one service or many.
You may even like:
Looking to promote your company, product, service, or event to 47,000+ Cloud Native Professionals? Let's work together.


