Search⌘ K
AI Features

Docker Volumes and Networks

Explore how Docker volumes help retain data in containers needing persistence, like databases, and understand Docker networks for container communication. Learn to manage port exposure in development and production environments to improve container security and interaction.

We'll cover the following...

Volumes

Containers do not retain state between restarts. This is generally a good thing. Any number of containers can be started from the same base image and each can handle incoming requests regardless of how or when they were launched.

However, some containers, such as databases, absolutely must retain data. So Docker provides two storage mechanism types:

  1. Volumes: a Docker-managed file system
  2. Bind mounts: a file or directory on the host machine

Either can map to a directory on the container, such as /data/db for MongoDB storage.

Volumes are the ...