Wbzard Labs
Docker for Beginners: Containers Explained Simply, with Your First Dockerfile
Back to Blog
Careers24 October 2026Vivek3 min read

Docker for Beginners: Containers Explained Simply, with Your First Dockerfile

You build a project on your laptop. It works. Your friend downloads it and gets ten errors: wrong Node version, missing database, different operating system. Multiply that by a team of 50 and a few servers, and you understand why companies adopted Docker.

What Docker does

Docker packages your application plus everything it needs (runtime, libraries, system tools, configuration) into a container. The container runs the same way on your laptop, a colleague's laptop, a test server and the cloud.

Analogy: a shipping container. The ship doesn't care whether it carries mangoes or machine parts; every container has the same shape and fits the same cranes. Docker containers have the same "shape" for servers.

Containers vs virtual machines

Virtual machineContainer
IncludesA full operating systemJust the app and its dependencies, sharing the host's kernel
SizeGigabytesOften megabytes
Start timeMinutesSeconds
UseRunning different operating systemsPackaging and running apps consistently

Key terms

  • Image: a read-only blueprint for your app (like a class)
  • Container: a running instance of an image (like an object)
  • Dockerfile: instructions to build an image
  • Registry: where images are stored and shared (Docker Hub, GitHub Container Registry, cloud registries)
  • Volume: storage that survives when a container is removed (for databases)
  • Port mapping: connecting a port on your machine to a port in the container

Your first Dockerfile (Node.js app)

For a simple Express app with package.json and index.js:

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]

Then:

docker build -t my-api .
docker run -p 3000:3000 my-api

Open http://localhost:3000. Your app is running inside a container.

Add a .dockerignore file with node_modules and .env so they aren't copied into the image.

Commands you'll use often

CommandWhat it does
docker build -t name .Build an image from a Dockerfile
docker run -p 3000:3000 nameRun a container
docker ps / docker ps -aList running / all containers
docker logs <id>See a container's output
docker exec -it <id> shOpen a shell inside a container
docker stop <id>Stop a container
docker imagesList images
docker compose up -dStart everything in compose.yaml

Docker Compose: running an app with a database

Real apps have several parts. A compose.yaml for a MERN-style backend:

services:
  api:
    build: .
    ports:
      - "3000:3000"
    environment:
      - MONGO_URL=mongodb://db:27017/app
    depends_on:
      - db
  db:
    image: mongo:7
    volumes:
      - mongo-data:/data/db
volumes:
  mongo-data:

Run docker compose up -d and both start together, connected on a private network.

Good habits

  • Use small, official base images (for example -alpine or -slim variants)
  • Never put passwords or keys in the Dockerfile; use environment variables or secrets
  • One main process per container
  • Pin versions (node:20-alpine, not node:latest) so builds are repeatable
  • Commit your Dockerfile and compose file to Git (Git and GitHub for beginners)

Where Docker fits in a DevOps career

  1. Linux and networking basics
  2. Git and a programming or scripting language
  3. Docker ← you are here
  4. CI/CD: build and push images automatically (GitHub Actions, Jenkins)
  5. Cloud: deploy containers on AWS, Azure or GCP
  6. Kubernetes: run many containers reliably at scale
  7. Monitoring and infrastructure as code

Full path: DevOps roadmap for beginners. Not sure between web development and DevOps? Read MERN vs DevOps.

Learn it with us

Our live online DevOps course for Shivamogga students covers Docker hands-on, from your first Dockerfile to deploying containers through a CI/CD pipeline. See all courses.

Filed underCareers

Wbzard Labs

Want this done for your business?

We help founders in Bangalore and Shivamogga launch with a website, social media, SEO and ads that work together. Tell us about your business and get a free launch plan.