목. 7월 24th, 2025

🐳 What is Docker?

Docker is a platform that lets you build, deploy, and run applications using containers. Containers package an app’s code, libraries, and dependencies into a single, lightweight unit that runs consistently anywhere. Think of it like a shipping container for software—your app works the same on your laptop, your colleague’s machine, or a cloud server.

Docker Containers
Containers package apps for seamless portability. (Source: Docker Official Docs)


❓ Why Use Docker?

  1. No More “It Works on My Machine!”
    Docker ensures apps run identically across all environments.
  2. Lightweight & Fast
    Containers share the host OS kernel, making them faster and smaller than virtual machines.
  3. Isolation
    Apps run in isolated environments—no conflicts between dependencies.

VM vs Containers
Containers vs. Virtual Machines: Containers are lighter and faster. (Source: Docker)


🔑 Core Concepts

  1. Docker Image
    A read-only template with instructions to create a container (e.g., nginx:alpine).
  2. Container
    A runnable instance of an image.
  3. Dockerfile
    A text file defining steps to build an image (e.g., base OS, code, dependencies).
  4. Docker Hub
    A cloud repository to share images (like GitHub for Docker).

🛠️ Basic Docker Commands

# Pull an image from Docker Hub
docker pull nginx:alpine

# Run a container from an image
docker run -d -p 8080:80 --name my-website nginx:alpine

# List running containers
docker ps

# Stop a container
docker stop my-website

# Build an image from a Dockerfile
docker build -t my-app:1.0 .

🚀 Your First Docker Project

  1. Create a Dockerfile:

    # Use the official Python image
    FROM python:3.9-slim
    # Set working directory
    WORKDIR /app
    # Copy code
    COPY . .
    # Install dependencies
    RUN pip install -r requirements.txt
    # Run the app
    CMD ["python", "app.py"]
  2. Build the Image:

    docker build -t my-python-app .
  3. Run the Container:

    docker run -d -p 5000:5000 my-python-app

    Visit http://localhost:5000 to see your app!


💡 Pro Tips for Beginners

  • Clean Up: Use docker system prune to remove unused containers/images.
  • Volumes: Persist data with -v (e.g., docker run -v /data:/app/data).
  • Docker Compose: Manage multi-container apps with a docker-compose.yml file.

🌐 Docker Architecture

Docker Architecture
Docker Engine manages containers, images, and networks. (Source: Docker Docs)


✅ Conclusion

Docker simplifies development by eliminating environment inconsistencies and streamlining deployment. Start small:

  1. Install Docker Desktop.
  2. Run docker run hello-world.
  3. Explore pre-built images on Docker Hub.

Containers are the future—and now you’re ready to ship! 🚀


All images sourced from Docker Official Documentation.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다