创建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
原文地址:https://www.cnblogs.com/yin5th/p/9128665.html
时间: 2024-10-16 21:19:00