Docker container management is available in 2 ways:
1: Data Volume: Linux-like directory mount mount
2: Data Volume container: In fact , a normal container, specifically used to provide data volumes for other containers to mount
Using Docker search XXX//xxx refers to searching for the appropriate image. Pull after search according to your needs
Download image
[Email protected]:~# Docker Pull Jdeathe/centos-ssh
View the mirror after pull
[Email protected]:~# docker imagesrepository TAG IMAGE ID CREATED VIRTUAL SIZEJDEATHE/CENTOS-SSH latest EBB3F7483E15 4 weeks ago 276.2 MB
Data volumes
Run the container name Node1 and mount the/data-node1 data volume inside the container
: ~# Docker run-itd--name node1-v/data-node1 jdeathe/centos-ssh/bin/ basha51fbc7cf66c4db39316e96b777f3a53900c25bcae8cb227491742b7f3fe6656
Enter the Node1 container
: ~#./docker-enter Node1
View mounted data volumes within a container
[[email protected] ~]# ll/data-node1/total 0[[email protected] ~]# ll/data-node1/-ddrwxr-xr-x 2 root root 4096 Dec 23 01:36/data-node1/
mount a local directory as a container node2 data volume
View Local Directory files
[Email protected]:~# ls/data/docker nginx web1 web2
Run container node2, local/data directory as a data volume for container node2
[Email protected]:~# docker run-itd--name node2-v/data:/data-node1 jdeathe/centos-ssh/bin/ bash0d935fcad74b00b86f0264c466853813426b3dc50ac6bd98377cfa608500b851
Enter the container Node2
: ~#./docker-enter Node2
View the Mount local directory corresponding data volume directory file information in the container
[[email protected] ~]# ls/data-node1/docker nginx web1 web2[[email protected] ~]# Cat/data-node1/docker this is a doc Ker containers
Container mount data volumes for other containers
[Email protected] ~]# Logout
Run the container node3, mount the data volume from the Container Node1 data volume
: ~# Docker run-itd--name node3--volumes-from node1 jdeathe/centos-ssh/bin/ Bash5a4ef366033418a4f1c1b8de02d32960ee413f525eb0398fb831074892010d45
Enter the Node3 container and view the relevant data volume directory file information
: ~#./docker-enter node3[[email protected] ~]# ls/data-node1/[[email protected] ~]# ls/data-node1/-d/data-node1/[[emai L protected] ~]# ls-l/data-node1/-ddrwxr-xr-x 2 root root 4096 Dec 01:36/data-node1/
Running other containers can still continue to mount data volumes for other containers
[Email protected] ~]# logout:~# Docker run-itd--name node4--volumes-from node1 jdeathe/centos-ssh/bin/bash571c7712da ecbf0c0bccf02b1b3e615d61b14aeba95360013dd35d5a277dfa03:~#./docker-enter node4[[email protected] ~]# ls-l/ data-node1/-ddrwxr-xr-x 2 root root 4096 Dec 01:36/data-node1/
Note: The above is about container creation data volume related information
This article is from the "Runny nose" blog, be sure to keep this source http://noodle.blog.51cto.com/2925423/1727486
Docker create data volumes and data volume containers