Docker Compose部署lnmp
参考: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的更多相关文章
- 使用Docker Compose部署基于Sentinel的高可用Redis集群
使用Docker Compose部署基于Sentinel的高可用Redis集群 https://yq.aliyun.com/articles/57953 Docker系列之(五):使用Docker C ...
- Docker Compose 部署前后端分离应用
部署前后端分离应用 容器化 Abp 应用 关于 Abp 应用的容器化,其实和普通的 ASP.NET Core 应用差不多,大家可以参考我此前的文章. 唯一需要注意的是:因为 Abp 解决方案中有多个项 ...
- Docker Compose部署项目到容器-基于Tomcat和mysql的项目yml配置文件代码
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- 在Windows Server 2019通过Docker Compose部署Asp.Net Core
一.安装Docker Enterprise 安装文档是: https://docs.docker.com/install/windows/docker-ee/ 安装完成后,如下图 二.首先,拉取一个W ...
- 使用Docker Compose 部署Nexus后初次登录账号密码不正确,并且在nexus-data下没有admin,password
场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/ ...
- Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程)
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- Docker Compose部署Nexus3时的docker-compose,yml代码
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- Docker Compose部署GitLab服务,搭建自己的代码托管平台(图文教程)
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- 使用Docker Compose 部署Nexus后提示:Unable to create directory /nexus-data/instance
场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/ ...
随机推荐
- IntelliJ IDEA return null with ClassLoader.getSystemResourceAsStream(“configFilename”));
参考https://stackoverflow.com/questions/49470053/intellij-idea-return-null-with-classloader-getsystemr ...
- git web找不到new project解决方法
group->选一个project->new project This is a annoying for two reasons: users might not understand ...
- jQuery的鼠标悬停时放大图片的效果
这是一个基于jQuery的效果,当鼠标在小图片上悬停时,会弹出一个大图,该大图会跟随鼠标的移动而移动.这个效果最初源于小敏同志的一个想法,刚开始做的时候只能实现弹出的图片是固定的,不能随鼠标移动,最后 ...
- andorid 列表视图之SimpleAdapter
.xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android=&qu ...
- Luogu1501 Tree II - LCT
Code #include<cstdio> #include<cstring> #include<algorithm> #define rd read() #def ...
- sqli-labs:11-16,post注入
sqli11: post:uname=xx' order by 2#&passwd=bla&submit=Submit(判定字段为2) 解释下为什么结果不是admin,这是sql执行的 ...
- linux fedora 的备份小技巧
大家都知道,在fedora中,是没有默认安装带有GUI的备份软件的. 我们可以去软件中心搜索“备份”或者“dup”来安装deja-dup来进行备份,这个软件就是ubuntu中设置的“备份”,只不过ub ...
- JS closure
闭包的概念 闭包,不同于一般的函数,它允许一个函数在立即词法作用域外调用时,仍可访问非本地变量. --维基百科 闭包就是能够读取其他函数内部变量的函数. --阮一峰 由于在Javascript语言中, ...
- 【Linux】开机自动启动脚本
Linux下(以RedHat为范本)添加开机开机自动启动脚本有两种方式; 本例系统:Linux(CentOS 7.2) 方法一 使用 /etc/rc.d/rc.local,自动启动脚本 #!/bin/ ...
- 【Java】导出word文档之freemarker导出
Java导出word文档有很多种方式,本例介绍freemarker导出,根据现有的word模板进行导出 一.简单导出(不含循环导出) 1.新建一个word文件.如下图: 2.使用word将文件另存为x ...