This article is mainly about how to use Dockerfile to build the image of the LNMP environment, provided that you have installed Docker one, new Dockerfile file .
From ubuntu:16.04
maintainer turtle "turtle@anasit.com"
RUN \
apt-key adv--keyserver hkp:// keyserver.ubuntu.com:80--recv 0xcbcb082a1bb943db && \
apt-get update && \
apt-get install-y Mariadb-server Mariadb-common && \
apt-get install-y php && \
apt-get install-y nginx && \
Apt-get install-y vim
# Configure Nginx
Copy./default/etc/nginx/sites-available/default
# Add startup script
ADD./start.sh/start.sh
RUN chmod 755/start.sh
cmd/start.sh && tail-f
# Expose ports.
EXPOSE 3306
EXPOSE 80
start.sh file
# start Nginx
service nginx start
# # start MySQL
service mysql start
# # start PHP7.0-FPM
Service PHP7.0-FPM Start
Default file
# should look at the following URL ' s in order to grasp a solid understanding # of Nginx config files in order t
O fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # # Generally, you'll want to move this file somewhere, and start with a clean # # # You should look at the following URL ' s I
n order to grasp a solid understanding # of Nginx Config files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # # Generally, you'll want to move the this file somewhere, and start with a clean # file but keep this around for reference.
Or just disable in sites-enabled.
# # See/usr/share/doc/nginx-doc/examples/for more detailed examples.
# # # Default Server Configuration # server {Listen default_server;
Listen [::]:80 default_server; # SSL Configuration # # LiSten 443 SSL Default_server;
# Listen [::]:443 SSL Default_server;
# # Note:you should disable gzip for SSL traffic.
# see:https://bugs.debian.org/773332 # # Read up on Ssl_ciphers to ensure a secure configuration. # see:https://bugs.debian.org/765782 # Self signed certs generated by the Ssl-cert package # Don ' t use t
Hem in a production server!
# # include snippets/snakeoil.conf;
root/var/www/html;
# ADD index.php to the list if is using PHP index index.php index.html index.htm index.nginx-debian.html;
server_name _; Location/{# First attempt-serve request as file, then # as directory, then fall back to displaying a
404. Try_files $uri $uri/= 404; # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ {include S
nippets/fastcgi-php.conf;
# with php7.0-cgi alone: # Fastcgi_pass 127.0.0.1:9000; # with Php7.0-fpm:fastcgi_pass Unix:/run/php/php7.0-fpm.sock; } # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #location ~/\.ht {# de
NY all; #}} # Virtual Host configuration for example.com # # You can move this to a different file under Sites-available/and sy
Mlink that # to sites-enabled/to enable it. # #server {# Listen, # Listen [::]:80; # # server_name example.com; # # Root/var/www/example.
com
# index index.html; # # location/{# Try_files $uri $uri/= 404; #} #}
ii. build dockerfile file
Docker build-t turtlell/lnmp:1.0.
third, run the image
Docker run-id-p 80:80-v/var/www/html:/var/www/html Turtlell/lnmp
iv. access to localhost
Access to localhost, running successfully, indicating successful build
For more information, visit GitHub