参考:https://github.com/micooz/docker-lnmp

一、简介

  使用Dcoekr镜像部署lnmp(Linux、Nginx、MySQL、PHP7)。

  1.1 结构 

app
└── src
└── index.php
docker-compose.yml
etc
└── localtime
mysql
├── conf
│ └── my.cnf
└── mysqldb
nginx
├── ca
│ ├── server.crt
│ └── server.key
├── conf.d
│ └── test.conf
└── nginx.conf
php-fpm
├── Dockerfile
├── php-7.2.3.tar.gz
├── php-fpm.conf
├── php.ini
├── var
│ ├── log
│ │
│ └── run

└── www.conf # app 静态文件
# /etc/localtime 同步时区
# mysqldb 数据存储

  

二、部署

  2.1 php-fpm Dockerfile  

FROM centos:latest
MAINTAINER bigberg RUN yum -y install gcc gcc-c++ gd-devel libxml2 libxml2-devel libcurl-devel \
openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng \
freestyle freestyle-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel
ADD php-7.2.3.tar.gz /tmp/
RUN cd /tmp/php-7.2.3 \
&& ./configure --prefix=/usr/local/php \
--with-curl --with-freetype-dir --with-gd \
--with-gettext --with-iconv-dir --with-kerberos \
--with-libdir=lib64 --with-libxml-dir --with-mysqli \
--with-openssl --with-pcre-regex --with-pdo-mysql \
--with-pdo-sqlite --with-pear --with-png-dir \
--with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib \
--with-bz2 --with-mhash --enable-fpm --enable-bcmath \
--enable-libxml --enable-inline-optimization --enable-gd-native-ttf \
--enable-mbregex --enable-mbstring --enable-opcache \
--enable-pcntl --enable-shmop --enable-soap --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-xml --enable-zip \
&& make && make install \
&& cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm \
&& chmod a+x /etc/init.d/php-fpm \
&& groupadd -g 1001 www \
&& useradd -g 1001 -u 1001 www EXPOSE 9000
CMD ["/usr/local/php/sbin/php-fpm", "--nodaemonize"]

Dockerfile

  2.2 docker-compose.yml

version: ''
services:
# web server
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
# app,挂在目录
- ./app/src:/usr/share/nginx/html
# ngnix configs
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d/:/etc/nginx/conf.d/:ro
# certificates
- ./nginx/ca/server.crt/:/etc/nginx/server.crt:ro
- ./nginx/ca/server.key/:/etc/nginx/server.key:ro
- ./etc/localtime:/etc/localtime:ro
links:
- php:php-cgi # PHP-FPM
php:
build: ./php-fpm
volumes:
- ./app/src:/usr/share/nginx/html
# php.ini
- ./php-fpm/php.ini:/usr/local/php/etc/php.ini:ro
- ./php-fpm/php-fpm.conf:/usr/local/php/etc/php-fpm.conf:ro
- ./php-fpm/www.conf:/usr/local/php/etc/php-fpm.d/www.conf:ro
- ./php-fpm/var:/usr/local/php/var
- ./etc/localtime:/etc/localtime:ro
links:
- mysql:mysql
ports:
- "9000:9000"
stdin_open: true
tty: true # database
mysql:
image: mysql:latest
ports:
# Allow client to access 3306
- "3306:3306"
volumes:
# my.cnf
- ./mysql/conf/my.cnf:/etc/mysql/conf.d/my.cnf
# your data will be stored in ./mysql
- ./mysql/mysqldb:/var/lib/mysql
- ./etc/localtime:/etc/localtime:ro
environment:
- MYSQL_ROOT_PASSWORD=123456

  2.3 构建  

$ docker-compose up --build

  2.4 查看

$ docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------------------------
composelnmp_mysql_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
composelnmp_nginx_1 nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
composelnmp_php_1 /usr/local/php/sbin/php-fp ... Up 0.0.0.0:9000->9000/tcp

  相关文档:https://github.com/Bigberg/docker/tree/master/compose-lnmp

Docker Compose部署lnmp的更多相关文章

  1. 使用Docker Compose部署基于Sentinel的高可用Redis集群

    使用Docker Compose部署基于Sentinel的高可用Redis集群 https://yq.aliyun.com/articles/57953 Docker系列之(五):使用Docker C ...

  2. Docker Compose 部署前后端分离应用

    部署前后端分离应用 容器化 Abp 应用 关于 Abp 应用的容器化,其实和普通的 ASP.NET Core 应用差不多,大家可以参考我此前的文章. 唯一需要注意的是:因为 Abp 解决方案中有多个项 ...

  3. Docker Compose部署项目到容器-基于Tomcat和mysql的项目yml配置文件代码

    场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...

  4. 在Windows Server 2019通过Docker Compose部署Asp.Net Core

    一.安装Docker Enterprise 安装文档是: https://docs.docker.com/install/windows/docker-ee/ 安装完成后,如下图 二.首先,拉取一个W ...

  5. 使用Docker Compose 部署Nexus后初次登录账号密码不正确,并且在nexus-data下没有admin,password

    场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/ ...

  6. Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程)

    场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...

  7. Docker Compose部署Nexus3时的docker-compose,yml代码

    场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...

  8. Docker Compose部署GitLab服务,搭建自己的代码托管平台(图文教程)

    场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...

  9. 使用Docker Compose 部署Nexus后提示:Unable to create directory /nexus-data/instance

    场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/ ...

随机推荐

  1. 在ALV界面添加下拉框

    1.在alv界面表单属性中设置 if wa_fieldcat-fieldname = 'YC_MARK'.              wa_fieldcat-edit = 'X'.           ...

  2. YII2中添加自定义模块

    有些时候系统功能过于复杂,这时我们需要通过模块把一些功能区分开来,便于管理与维护. 我用的是Yii2的基本应用程序模板,程序其实已经给我们提供了一个模块,就是app本身.YII2中是可以无限嵌套模块的 ...

  3. java类中根据已有的变量复写类的toString方法

    java类中根据已有的变量复写类的toString方法: 在该类中定义好变量之后,shift+alt+s,从出现的列表中点击gemerate toString,就会自动生成对应的toString方法.

  4. c#设计模式3抽象工厂模式(Abstract Factory)

    #region 坦克系列 abstract class Tank { abstract public void Go(); } /// <summary> /// 越野车 /// < ...

  5. 24.Mysql高级安装和升级

    24.Mysql高级安装和升级24.1 Linux/Unix平台下的安装 24.1.1 安装包比较Linux下的Mysql安装包分为RPM包.二进制包.源码包3种.RPM包优点是安装简单,适合初学者: ...

  6. Contest with Drinks Easy

    /* Problem Statement Joisino is about to compete in the final round of a certain programming competi ...

  7. Android.FamousBlogs

    1. cyrilmottier http://cyrilmottier.com/ http://cyrilmottier.com/about/ 2. greenrobot http://greenro ...

  8. Python.SQLAlchemy.0

    1. SQLAlchemy and You http://lucumr.pocoo.org/2011/7/19/sqlachemy-and-you/ 2. Overview http://docs.s ...

  9. windows下git的使用方法(码云)

    这表文章主要是用了可视化操作: 使用命令行操作:https://www.cnblogs.com/mswyf/p/9370238.html 一.安装Git Bash 为了在windows下使用Git,我 ...

  10. 关于Spring父容器和SpringMvc子容器

    在SSM项目中,会有SpringMvc容器(子容器)和Spring容器(父容器) 一共2个容器 基本规则: 子容器可以访问父容器的bean,父容器不能访问子容器的bean. 当<context: ...