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

The method of remote mounting Volume in docker running Container

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Use of volumes in docker containers

There are several ways to create a volume itself, such as the following:

Here are the official basic steps:

Create a volume: $docker volume create my-vol View: $docker volume lslocal my-vol View details of the volume: $docker volume inspect my-vol [{"Driver": "local", "Labels": {}, "Mountpoint": "/ var/lib/docker/volumes/my-vol/_data", "Name": "my-vol", "Options": {} "Scope": "local"}] remove volume: $docker volume rm my-vol

Next, on this basis, you need to use volume drive, and the specific steps are as follows:

Install vieux/sshfs as a volume driver

# Volume plug installation $docker plugin install-grant-all-permissions vieux/sshfs

Create a volume

Where sshcmd and password represent the mount point of the remote host and the ssh login password

Docker volume create-driver vieux/sshfs\-o sshcmd=192.168.5.106:/home/xzg\-o password=xzg\ sshvolume

Use an existing image to create a container

# View existing images: [root@localhost docker] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx latest da5939581ac8 7 days ago 108MB# use local images to create containers docker run-d\-it\-- name sshfs-container\-- mount src=sshvolume,target=/app,type=volume,volume-driver=vieux/sshfs\ da5939581ac8

Enter the container to see if the mount is successful.

[root@localhost docker] # docker exec-it 228d13ee572a bashroot@228d13ee572a:/# lsapp bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr varroot@228d13ee572a:/# cd app/root@228d13ee572a:/app# lsa.txt docker

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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

Servers

Wechat

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

12
Report