How docker shares data

"Shared Data : "

1. Containers and hosts

docker cp

 

2. Containers and containers:

docker run --name web1 -d -p 80 -v /root/htdocs:/usr/local/apache2/htdocs httpd

 

 

3.Volume container share data:

(1) Create a container for mounting, where vc_data only provides data and does not need to be run, and then map the other three containers to the directory mounted by vc_data to achieve data sharing. No need to mount one by one.

 

docker create --name vc_data -v /root/htdocs:/usr/local/apache2/htdocs -v /root/tools -v /root/lpc/  busybox

Note: 1. Multiple directories can be mounted at the same time

 

(2) Map the mounts of multiple containers to the newly created container vc_data.

docker run --name web10 -d -p 80 --volumes-from vc_data httpd

docker run --name web20 -d -p 80 --volumes-from vc_data httpd

docker run --name web30 -d -p 80 --volumes-from vc_data httpd

 

(3) Verification

View the homepage:

curl ip:port

curl 192.168.6.110:32771

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324879641&siteId=291194637