george alonge
kubernetes

Docker For Beginners: How to Build Your First Container

A beginner's guide to understanding what Docker is and what it is not — build your first container step by step.

A beginner's guide to understanding what Docker is and what it is not.

Docker has revolutionized how we build, ship, and run applications. At its core, Docker allows you to package an application and its dependencies into a standardized unit called a container.

What is Docker?

  • Not a virtual machine — containers share the host OS kernel
  • Lightweight — start in seconds, use minimal resources
  • Portable — run the same container anywhere
  • Isolated — each container has its own filesystem and network

Key Concepts

  • Image: A read-only template with instructions for creating a container
  • Container: A running instance of an image
  • Dockerfile: A text file that contains instructions for building an image
  • Registry: A repository for Docker images (e.g., Docker Hub)

Building Your First Container

FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

Build and run with:

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