The method of remote mounting Volume in docker running Container
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.