(七)Docker搭建httpd集群

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. 参考

转载于:https://www.cnblogs.com/walkinginthesun/p/9563745.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值