码迷,mamicode.com
首页 > 其他好文 > 详细

docker 搭建laravel开发环境

时间:2018-06-03 14:46:57      阅读:414      评论:0      收藏:0      [点我收藏+]

标签:amp   use   har   software   pack   ali   pid   from   worker   

创建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 "541304803@qq.com"

# 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 "541304803@qq.com"

# 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 "541304803@qq.com"

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开发环境

标签:amp   use   har   software   pack   ali   pid   from   worker   

原文地址:https://www.cnblogs.com/yin5th/p/9128665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!