18 posts
Data Volumes
docker container run -d -p 3307:3306 --name mysql_db -e MYSQL_RANDOM_ROOT_PASSWORD=True mysql
docker volume ls
docker volume inspect <id>
We can't say which volume is attached to which container
named volumes
docker container run -d -p 3307:3306 --name mysql_db1 -e MYSQL_RANDOM_ROOT_PASSWORD=True -v mysql_data:/var/lib/mysql mysql
docker container rm -f mysql_db1
docker container run -d -p 3307:3306 --name mysql_db2 -e MYSQL_RANDOM_ROOT_PASSWORD=True -v mysql_data:/var/lib/mysql mysql
docker volume ls
we can see only one volume with name `mysql_data`, so data is persistant.
Bind mounting
docker container run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx
then we can login to that container and see the all files.
Any changes in host location also reflects there without restart/reload (persistant)
Please log in to leave a comment.
18 posts