Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement Docker volume Mount Volume

Shulou Source: shulou.com Published: 2022-06-01 03:42:46 10月04日 Update

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.

Tags: Files knowledge articles runs mirrors facets contents times different big code information commands most that is instructions are in more directories knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft Docker NVidia MariaDB