Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of remote mounting Volume in docker running Container

Shulou Source: shulou.com Published: 2022-06-02 00:47:32 10月04日 Update

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.

Tags: Container image step driver success next host content foundation variety official password that is plug-ins methods details learning help support login Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Microsoft Redmi Xiaomi