Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Docker volume Mount Volume

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report