What is Docker?

Docker is a platform for building, shipping, and running applications in containers. A container packages your app and its dependencies into a single runnable unit that behaves the same on your laptop, a VM, or a server.

Why use it?

  • Consistency — “It works on my machine” becomes “it works in the container” everywhere.
  • Isolation — Each container has its own filesystem and network; you can run many services on one host without conflicts.
  • Portability — Images are reusable; pull once, run anywhere that has Docker.

Run your first container

Install Docker for your OS (docs), then:

bash
docker run hello-world

Docker pulls the hello-world image (if needed) and runs it. You should see a short message.

Run something useful

bash
docker run -d -p 8080:80 --name my-nginx nginx:alpine
  • -d — run in the background
  • -p 8080:80 — map host port 8080 to container port 80
  • --name my-nginx — give the container a name
  • nginx:alpine — image to run

Open http://localhost:8080; you should see the default nginx page. Stop and remove the container:

bash
docker stop my-nginx
docker rm my-nginx

Next

In Part 2 we’ll use Docker Compose to define and run multi-container apps from a single file.