What Is Docker and Why Should You Care?
Docker lets you package your application and all its dependencies into a single, portable unit called a container. Containers run identically on your laptop, your teammate's machine, and in production — eliminating the classic "it works on my machine" problem.
Before Docker, deploying an app meant carefully matching OS versions, runtime versions, and library versions across every environment. Docker solves this by bundling everything your app needs into one image.
Key Concepts
- Image – A read-only blueprint for a container (think of it like a class in OOP).
- Container – A running instance of an image (like an object instantiated from that class).
- Dockerfile – A text file with step-by-step instructions for building an image.
- Registry – A storage service for images (Docker Hub is the public default).
Installing Docker
Download Docker Desktop from [docker.com](https://docker.com) for macOS or Windows. On Linux:
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USERVerify the install:
docker --version
docker run hello-worldWriting Your First Dockerfile
Let's containerize a simple Node.js app. Create a file named Dockerfile (no extension) in your project root:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]Breaking this down:
FROM node:20-alpine— start from an official Node.js image built on Alpine Linux (small footprint).WORKDIR /app— all subsequent commands run inside/app.COPY package*.json ./thenRUN npm ci— install dependencies first so Docker can cache this layer.COPY . .— copy your source code after dependencies are installed.EXPOSE 3000— documents which port the app listens on.CMD— the default command when the container starts.
Building and Running
# Build the image and tag it
docker build -t my-app:1.0 .
# Run the container, mapping host port 8080 to container port 3000
docker run -p 8080:3000 my-app:1.0Visit http://localhost:8080 and your app is live inside a container.
Essential Docker Commands
docker ps # list running containers
docker ps -a # list all containers (including stopped)
docker images # list local images
docker logs <container-id> # view container stdout/stderr
docker exec -it <id> sh # open a shell inside a running container
docker stop <container-id> # gracefully stop a container
docker rm <container-id> # remove a stopped container
docker rmi my-app:1.0 # remove an imagePushing to a Registry
docker tag my-app:1.0 yourusername/my-app:1.0
docker push yourusername/my-app:1.0Deploying to PandaStack
Once your image is built and pushed, deploying to production takes seconds. PandaStack supports bring-your-own-Dockerfile container deployments directly from GitHub — no need to push to a registry manually.
Install the CLI:
npm install -g @pandastack/cliThen deploy:
panda deploy --type container --repo your-org/your-repoPandaStack builds the image from your Dockerfile, provisions the container, and gives you a live HTTPS URL. Manage everything from [dashboard.pandastack.io](https://dashboard.pandastack.io) or read the full docs at [docs.pandastack.io](https://docs.pandastack.io).
Next Steps
You now understand the full cycle: write a Dockerfile → build an image → run a container → deploy. From here, explore multi-stage builds for smaller images, Docker Compose for multi-service local development, and container resource limits for production stability. Docker is the foundation of modern cloud deployment — mastering it opens the door to scalable, reliable infrastructure.