DockerFile部署lnmp+memcached+redis+mongodb开发环境for Nginx

Posted 93bok

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DockerFile部署lnmp+memcached+redis+mongodb开发环境for Nginx相关的知识,希望对你有一定的参考价值。

本文源链接地址:https://www.93bok.com

1、下载基础镜像centos
docker pull centos:6
2、查看一下大小
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              6                   70b5d81549ec        2 months ago        195MB
3、创建文件夹存放nginx的Dockerfile,以及源码包等等,为后期docker-compose做准备
mkdir -p /data/docker/lnmp-test/dockerfile/nginx
4、创建Mongodb的Dockerfile
vim /data/docker/lnmp-test/dockerfile/nginx/Dockerfile
FROM centos:6

LABEL maintainer="[email protected]" description="Nginx image"

ENV NGINX_VERSION 1.8.1

COPY 3rdPartyModules /root/3rdPartyModules

RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 && CONFIG="        --prefix=/usr/local/nginx         --conf-path=/etc/nginx/nginx.conf         --pid-path=/var/run/nginx.pid         --with-http_ssl_module         --user=nginx         --group=nginx         --error-log-path=/var/log/nginx/error.log         --http-log-path=/var/log/nginx/access.log         --http-client-body-temp-path=/usr/local/nginx/client_temp         --http-proxy-temp-path=/usr/local/nginx/proxy_temp         --http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp         --http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp         --http-scgi-temp-path=/usr/local/nginx/scgi_temp         --with-threads         --with-file-aio         --with-http_realip_module         --with-http_addition_module         --with-http_gunzip_module         --with-http_gzip_static_module         --add-module=/root/3rdPartyModules/echo-nginx-module-0.58/         --add-module=/root/3rdPartyModules/nginx-http-concat-1.2.2" && yum install -y                 gcc                 pcre-devel                 openssl-devel && groupadd nginx && useradd -s /sbin/nologin -M -g nginx nginx && tar -zxvf /root/3rdPartyModules/nginx-$NGINX_VERSION.tar.gz -C /root/3rdPartyModules/ && cd /root/3rdPartyModules/nginx-$NGINX_VERSION && ./configure $CONFIG && make -j $(getconf _NPROCESSORS_ONLN) && make install && mkdir -p /etc/nginx/conf.d && ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ && chown -R nginx:nginx /usr/local/nginx/ && rm -rf /root/3rdPartyModules/ && yum clean all

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
5、把nginx源码包和扩展包上传到/data/docker/lnmp-test/dockerfile/nginx/目录下
6、创建镜像
cd /data/docker/lnmp-test/dockerfile/nginx/
docker build -t centos6:nginx .
7、查看镜像大小
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos6             nginx               4a86f591315d        28 minutes ago      388MB
centos              6                   70b5d81549ec        2 months ago        195MB
8、启动容器测试是否成功
docker run -d -p 80:80 --name nginx centos6:nginx

技术分享图片

9、宿主机开启防火墙80端口
firewall-cmd --add-port=80/tcp --permanent
systemctl restart firewalld

以上是关于DockerFile部署lnmp+memcached+redis+mongodb开发环境for Nginx的主要内容,如果未能解决你的问题,请参考以下文章

DockerFile部署lnmp+memcached+redis+mongodb开发环境for MySQL

DockerFile部署lnmp+memcached+redis+mongodb开发环境for Redis

DockerFile部署lnmp+memcached+redis+mongodb开发环境for Nginx

DockerFile部署lnmp+memcached+redis+mongodb开发环境for PHP

部署网站运行平台LNMP + Memcached缓存

LNMP动静分离&&memcache缓存服务器