filmov
tv
Docker volume with example | Volume mounted to mysql container

Показать описание
$ docker run --name some-mysql -v /home/tamizh/mysqlbackup:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
--name - name of container
-v - volume
-e - environmental variable
-d - run the container in background
volume:
- what happens if our container fails, deleted or crashed during its execution?
There will be loss of data, so for the containers with persistant data we need to use volume. so a copy of data will be saved in specified location and when the container is restored it will not face data loss....
eg: if your db is in container lets mount it to a path in your local machine. data will be saved.
/var/lib/mysql - this is the path in the container where mysql stores its data.
we will be mounting it to our local machine using
-v /home/tamizh/mysqlbackup:/var/lib/mysql
--name - name of container
-v - volume
-e - environmental variable
-d - run the container in background
volume:
- what happens if our container fails, deleted or crashed during its execution?
There will be loss of data, so for the containers with persistant data we need to use volume. so a copy of data will be saved in specified location and when the container is restored it will not face data loss....
eg: if your db is in container lets mount it to a path in your local machine. data will be saved.
/var/lib/mysql - this is the path in the container where mysql stores its data.
we will be mounting it to our local machine using
-v /home/tamizh/mysqlbackup:/var/lib/mysql