1. 程式人生 > >DockerFile部署lnmp+memcached+redis+mongodb開發環境for Nginx(一)

DockerFile部署lnmp+memcached+redis+mongodb開發環境for Nginx(一)

name tor dir wall ech permanent roo emp login

本文源鏈接地址: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(一)