Docker compose 一键部署LNMP平台

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker compose 一键部署LNMP平台相关的知识,希望对你有一定的参考价值。

docker-compose.yml

version: ‘3‘
services:
  nginx:
    hostname: nginx
    build:
      context: ./nginx
      dockerfile: Dockerfile
    ports:
      - 80:80
    links:
      - php:php-cgi
    volumes:
      - ./wwwroot:/usr/local/nginx/html

  php:
    hostname: php
    build: ./php
    links:
      - mysql:mysql-db
    volumes:
      - ./wwwroot:/usr/local/nginx/html

  mysql:
    hostname: mysql
    image: mysql:5.6
    ports:
      - 3306:3306
    volumes:
      - ./mysql/conf:/etc/mysql/conf.d
      - ./mysql/data:/var/lib/mysql
    # command: --character-set-server=utf8
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: wordpress
      MYSQL_USER: user
      MYSQL_PASSWORD: user123

nginx Dockerfile(配置文件和root目录都在当前路径下)

FROM centos:6
MAINTINER dengwenlong
RUN yum install -y gcc gcc-c++ make openssl-devel pcre-devel
ADD nginx-1.14.0.tar.gz /tmp
RUN cd /tmp/nginx-1.14.0.tar.gz && ./configure --prefix=/usr/local/nginx && make && makeinstall
COPY nginx.conf /usr/local/nginx/conf
EXPOSE 80
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]

mysql(使用docker pull mysql:5.6 镜像)

mkdir conf
mkdir data

php Dockerfile

FROM centos:6
MAINTAINER dengwenlong
RUN yum install -y gcc gcc-c++ gd-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel openssl-devel
ADD php-5.6.31.tar.gz /tmp/
RUN cd /tmp/php-5.6.31 &&     ./configure --prefix=/usr/local/php     --with-config-file-path=/usr/local/php/etc     --with-mysql --with-mysqli     --with-openssl --with-zlib --with-curl --with-gd     --with-jpeg-dir --with-png-dir --with-iconv     --enable-fpm --enable-zip --enable-mbstring &&     make -j 4 && make install &&     cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf &&     sed -i "s/127.0.0.1/0.0.0.0/" /usr/local/php/etc/php-fpm.conf &&     cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm &&     chmod +x /etc/init.d/php-fpm 
COPY php.ini /usr/local/php/etc
EXPOSE 9000
CMD /etc/init.d/php-fpm start && tail -F /var/log/messages

以上是关于Docker compose 一键部署LNMP平台的主要内容,如果未能解决你的问题,请参考以下文章

Docker Compose一键搭建lnmp开发环境

docker-compose部署lnmp环境

一键部署LNMP平台脚本

dnmp一键部署搞定的php开发环境基于Docker的LNMP一键安装程序

Docker Compose 一键部署Nginx代理Tomcat集群

docker-compose入门示例:一键部署 Nginx+Tomcat+Mysql