1. 单个httpd镜像
[root@Thor ~]# docker run -dit -p 1992:80 -v my_volume:/usr/local/apache2/htdocs --name httpd httpd
5026e9cc9e6df434f2d3649aee69aa348cd0971d0e4d62783d38cc7e07be4510
[root@Thor ~]#
[root@Thor ~]# docker volume ls
DRIVER VOLUME NAME
local my_volume
[root@Thor ~]#
[root@Thor ~]# docker volume help
Usage: docker volume COMMAND
Manage volumes
Options:
--help Print usage
Commands:
create Create a volume
inspect Display detailed information on one or more volumes
ls List volumes
prune Remove all unused volumes
rm Remove one or more volumes
Run 'docker volume COMMAND --help' for more information on a command.
[root@Thor ~]#
[root@Thor ~]# docker volume inspect my_volume
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/my_volume/_data",
"Name": "my_volume",
"Options": {},
"Scope": "local"
}
]
[root@Thor ~]# cd /var/lib/docker/volumes/my_volume/_data
[root@Thor _data]# ls
data test.txt
[root@Thor _data]# cp /home/aliyun.jpg ./
[root@Thor _data]# ls
aliyun.jpg data test.txt
[root@Thor _data]# ll
total 284
-rw-r----- 1 root root 285872 Aug 30 20:08 aliyun.jpg
drwxr-xr-x. 2 systemd-bus-proxy root 22 Jul 17 16:59 data
-rw-r--r--. 1 root root 20 Jul 16 16:41 test.txt
[root@Thor _data]# chmod 777 *
[root@Thor _data]#
2. httpd集群
[root@Thor swarm_httpd]# docker service create --replicas 10 --name httpd -p 1993:80 --mount type=volume,source=my_volume,destination=/usr/local/apache2/htdocs httpd:latest
it4qba7ctf8h14kxcjqe5ckg2
[root@Thor docker]# docker service ps httpd
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
vxy7otglyzwv httpd.1 httpd:latest Thor Running Running 23 minutes ago
op29u6288qju httpd.2 httpd:latest Thor Running Running 23 minutes ago
mm5hgjujighc httpd.3 httpd:latest Thor Running Running 23 minutes ago
dtl794xpmwxw httpd.4 httpd:latest Thor Running Running 23 minutes ago
lmyokyb7wbug httpd.5 httpd:latest Thor Running Running 23 minutes ago
tf8dmja5micb httpd.6 httpd:latest Thor Running Running 23 minutes ago
9tf0e6qbkn15 httpd.7 httpd:latest Thor Running Running 23 minutes ago
jh9c6mg9se8t httpd.8 httpd:latest Thor Running Running 23 minutes ago
qk2sixau15zo httpd.9 httpd:latest Thor Running Running 23 minutes ago
u6jfybeq8jhz httpd.10 httpd:latest Thor Running Running 23 minutes ago
3. 参考