Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Docker Docker & Containers: From Zero to Production Docker Compose Module 6 — Docker Compose Networking Volumes

Volumes and Networks in Docker Compose

Reviewed & accurate
AI Summary

What You'll Learn

Beginner

  • How to define volumes in Compose
  • How to define custom networks
docker-compose.ymlyaml
services:
  db:
    image: postgres:15
    volumes:
      - db-data:/var/lib/postgresql/data
  web:
    image: nginx
    volumes:
      - ./html:/usr/share/nginx/html:ro
    networks: [frontend]

volumes:
  db-data:

networks:
  frontend:

Key Takeaways

  • Named volumes: declare under volumes:.
  • Bind mounts: ./host:/container with :ro.
  • Compose creates a default network automatically.
  • Custom networks: declare under networks:.
Previously: Lesson 36 covered multi-service.
Today: You learned: How to use volumes and networks in Compose.
Next: Lesson 38 covers dev vs prod.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments