一、简介
目的:使用Docker Swarm 搭建lnmp来部署WordPress
- 使用Dockerfile构建nginx、php镜像
- 将构建的镜像上传docker私有仓库
- 使用volume做workpress网站文件持久化(每个工作节点都要保存一份数据)
- 使用nfs共享存储做ngixn配置文件持久化(一份数据多个工作节点共享)
- mysql镜像直接从dockerhub中获取
- mysql的配置文件使用docker config创建(当然也可以用挂载的方式)
- mysql 数据使用volume数据卷持久化
- 启动是mysql--php--nginx
二、准备
(1)如何创建私有仓库: http://www.cnblogs.com/bigberg/p/8821872.html
# 已经创建好的私有库中的镜像
[root@manager ~]# curl http://172.16.60.95:5000/v2/_catalog
{"repositories":["busyboxx","nginx","php"]}
# 其中nginx和php是准备要用的
(2)Dockerfiel文件
1 FROM centos:latest 2 MAINTAINER bigberg 3 RUN yum -y install pcre-devel openssl-devel net-tools gcc gcc-c++ zlib zlib-devel \ 4 make openssl 5 ADD nginx-1.12.1.tar.gz /tmp/ 6 RUN cd /tmp/nginx-1.12.1 \ 7 && ./configure --prefix=/usr/local/nginx \ 8 --with-http_ssl_module \ 9 --with-http_gzip_static_module \ 10 --with-http_realip_module \ 11 && make && make install 12 13 ADD nginx.conf /usr/local/nginx/conf/nginx.conf 14 15 RUN mkdir -p /usr/local/nginx/logs \ 16 && mkdir -p /usr/local/nginx/conf/vhosts \ 17 && groupadd -g 1001 nginx \ 18 && useradd -g 1001 -u 1001 -s /sbin/nologin -M nginx 19 RUN cat /usr/share/zoneinfo/Asia/Shanghai > /etc/localtime 20 21 EXPOSE 80 22 EXPOSE 443 23 CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]