docker 搭建laravel开发环境
Posted yin5th
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 搭建laravel开发环境相关的知识,希望对你有一定的参考价值。
创建nginx镜像
1. Dockerfile
# Based on docker image nginx # Add some softwares or php extensions that laravel5.5(or higher) needs. # Added softwares lists:composer FROM nginx MAINTAINER yin5th "[email protected]" # Create the virtual host configuration file directory #RUN mkdir -p /etc/nginx/sites-enabled # Copy nginx.conf ADD config/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 EXPOSE 443
2. config/nginx.conf
user nginx; worker_processes 2; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
3. Build 镜像
docker build -t yin5th/nginx .
创建php镜像
1. Dockerfile
# Based on docker image php:7.1-fpm # Added softwares lists:composer FROM php:7.1-fpm MAINTAINER yin5th "[email protected]" # Update package lists RUN apt-get update # Add composer and change the mirror source of composer to the domestic mirror RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer && composer config -g repo.packagist composer https://packagist.phpcomposer.com RUN mkdir -p /data VOLUME ["/data"]
2. Build 镜像
docker build -t yin5th/php:7.1 .
创建data镜像
1. Dockerfile
FROM debian:jessie MAINTAINER yin5th "[email protected]" RUN mkdir -p /data VOLUME ["/data"] CMD ["true"]
2. Build 镜像
docker build -t yin5th/data .
3. 创建数据卷容器
docker run --name laravel-data -d -v $HOME/code/php/www/mine/lara-55:/data yin5th/data
运行php容器
docker run --privileged=true --name lara-55-php --volumes-from laravel-data -d yin5th/php:7.1
运行nginx容器并链接到lara-55-php容器
docker run --privileged=true --name laravel-web --volumes-from laravel-data -p 80 --link lara-55-php -d yin5th/nginx
以上是关于docker 搭建laravel开发环境的主要内容,如果未能解决你的问题,请参考以下文章
本地使用 docker 快速搭建一个 PHP7.4 学习环境 | Laravel China 社区
centos7,docker版本搭建lnmp环境,部署laravel项目,解决大坑,新手教学
docker 从入门到自动化构建 PHP 环境 | Laravel China 社区
spring练习,在Eclipse搭建的Spring开发环境中,使用set注入方式,实现对象的依赖关系,通过ClassPathXmlApplicationContext实体类获取Bean对象(代码片段