Q6: Run a mysql container again, but this time map a volume to the container so that the data stored by the container is stored at /opt/data on the host.
Use the same name : mysql-db and same password: db_pass123 as before. Mysql stores data at /var/lib/mysql inside the container.
I tried the newer --mount option,
$ docker run -d --name=mysql-db -e MYSQL_ROOT_PASSWORD=db_pass123 --mount type=bind source=/opt/data target=/var/lib/mysql mysql
However this error with the below error,
invalid argument “type=bind” for “–mount” flag: target is required
OR
$ docker run -d --name mysql-db -e MYSQL_ROOT_PASSWORD=db_pass123 --mount type=bind,source=/opt/data,target=/var/lib/mysql mysql
docker: Error response from daemon: invalid mount config for type “bind”: bind source path does not exist: /opt/data.
How should we use this.
##Note: i used the -v option and that works all right.
Note that I did try the --mount command you mentioned, i.e.
docker run -d --name mysql-db -e MYSQL_ROOT_PASSWORD=db_pass123 --mount type=bind,source=/opt/data,target=/var/lib/mysql mysql
but it throws error
$ docker run -d --name mysql-db -e MYSQL_ROOT_PASSWORD=db_pass123 --mount type=bind,source=/opt/data,target=/var/lib/mysql mysql
docker: Error response from daemon: invalid mount config for type “bind”: bind source path does not exist: /opt/data.