Index Keywords Recent

↶ Return Home

Docker Volumes

Last Updated July 17th 2022, 11:48:17 am

Description

Docker volumes are file systems that are stored on the host and mounted in the Docker containers. They are used to preserve data independent of the container life cycle.[1]

Videos

Types of Volumes

Host Volumes

-v /path/on/host:/path/in/container

Anonymous Volumes

-v /path/in/container

Named Volumes

-v volume_name:/path/in/container

docker compose

Named Volume Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: '3'
services:
mongodb:
image: mongo
ports:
- 27017:27017
volumes:
- db-data:/var/lib/mysql/data
service_two:
image: coolio
ports:
- 8080:8080
volumes:
- db-data:/var/lib/data
volumes:
db-data:
driver: local

docker volume command

docker volume inspect [volume_name]


  1. https://phoenixnap.com/kb/docker-volumes#:~:text=What are Docker Volumes%3F,file systems between containers easily. ↩︎