Docker is a containerization platform that enables developers to package applications and their dependencies into lightweight, portable containers. These containers can run consistently across different environments, from development laptops to production servers, solving the "it works on my machine" problem.
# Use official Node.js runtime as base image
FROM node:18-alpine
# Set working directory in container
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy application code
COPY . .
# Expose port 3000
EXPOSE 3000
# Define environment variable
ENV NODE_ENV=production
# Run the application
CMD ["npm", "start"]
# Build an image from Dockerfile
docker build -t myapp:latest .
# Run a container
docker run -d -p 3000:3000 --name myapp-container myapp:latest
# List running containers
docker ps
# Stop a container
docker stop myapp-container
# Remove a container
docker rm myapp-container
# Pull an image from registry
docker pull nginx:latest
# View container logs
docker logs myapp-container
# Execute command in running container
docker exec -it myapp-container /bin/sh
Average DevOps Engineer Salary
Of Companies Use Containerization
Docker-Related Job Openings
Join thousands of professionals who've advanced their careers with Lead With Skills. Learn Docker, containerization, and modern DevOps practices from industry experts.