We'll show you how Docker volumes work. They allow you to mount a directory from your machine to the docker container. This is cool because any changes to files you make on your machine get immediately reflected within the docker container. We'll provide a demo and show you both ways to use Docker volumes. This tutorial goes through Docker Volumes and how to use them in 2 ways:
- -v option
- --mount option
Commands
docker run -v $(pwd)/data:/data -P --rm -d httpd
docker run -v $(pwd)/htdocs:/usr/local/apache2/htdocs -P --rm -d httpd
docker run --mount source=htdocs,target=/usr/local/apache2/htdocs -P --rm -d httpd
Links:
- Docker Docs: Use volumes
- GitHub: boltops-learn/docker-volumes
Docker Essentials
1h 46m
Explore lesson as part of a learning path
Get full access to these great resources
All for less than the price of coffee a day