From the course: Docker for Developers: Create and Manage Docker Containers
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Using a Docker volume - Docker Tutorial
From the course: Docker for Developers: Create and Manage Docker Containers
Using a Docker volume
- [Instructor] Volumes are your best friend for saving data between container restarts. Without them, every time you take down your database container, your data disappears. Volumes give you data persistence, and setting them up is simple. Take a look at your compose file in VS Code. At the bottom of the file on line 23 we're defining a volume. We're naming it pgdata. This volume can be used by any service defined in the compose file. If this volume doesn't exist, Docker Compose will create it for you when you run the containers. The only service that needs to use this volume is the DB service. On lines 20 and 21, the volume is set by using the name of the volume and a colon. The file path here is the location inside the container where the volume is mounted. If you wanted to create this volume before running the DB container, you would use the docker volume create command, and then the name of the volume. This…
Contents
-
-
-
-
-
-
-
(Locked)
Comparing Docker volumes and bind mounts2m 2s
-
(Locked)
Using a Docker volume4m
-
(Locked)
Using a bind mount3m 1s
-
(Locked)
Creating a custom network4m 16s
-
(Locked)
Challenge: Working with persistent storage and networks1m
-
(Locked)
Solution: Working with persistent storage and networks2m 5s
-
(Locked)
-
-
-
-