How to implement Docker volume Mount Volume
Today, I would like to share with you how to achieve the relevant knowledge of Docker volume mount volume, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.
For example, let's create a dockerfile file:
Where:
Volume: to create a mount point in container, we can mount a local file volume under / data in container, so that what we do in container's data directory is the same as in the local volume.
Cmd: only one command can be run when container starts.
All you need to do to create an image is to count the information in a file and enter it into 2.txt. Use $docker build-t count:v1. / to create a mirror and view
At run time, we need to add-v / root/laipeng.han/file:/data to mount the local file / root/laipeng.han/file under / data of container, so that all files under / root/laipeng.han/file can be seen under / data/ of container.
The running instruction is: docker run-v / root/laipeng.han/file:/data count:v1
The resulting file 2.txt, output by container under / data/, can also be seen under / root/laipeng.han/file/. In this way, we can modify the countfile.py code under / root/laipeng.han/file/ and run it directly without having to create a new image file.
These are all the contents of the article "how to achieve Docker volume Mount Volume". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.