标签:docker
[root@iZwz92l6rbipfcgz6jol18Z lnmp]# tree .[root@iZwz92l6rbipfcgz6jol18Z nginx]# cat Dockerfile
FROM centos:6
MAINTAINER PZY
RUN yum install gcc gcc-c++ make openssl-devel pcre-devel
ADD nginx-1.12.2.tar.gz /usr/local/src/
WORKDIR /usr/local/src/nginx-1.12.2
RUN ./configure --prefix=/usr/local/nginx && make -j 4 && make install
COPY nginx.conf /usr/local/nginx/conf
EXPOSE 80
CMD ["/usr/local/nginx/sbin/nginx","-g","daemon off;"]
[root@iZwz92l6rbipfcgz6jol18Z php]# cat Dockerfile
FROM centos:6
MAINTAINER pzy
RUN yum install -y gcc gcc-c++ gd-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel openssl-devel
ADD php-5.6.34.tar.gz /usr/local/src/
WORKDIR /usr/local/src/php-5.6.34
RUN ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql --with-mysqli --with-openssl --with-zl
ib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-iconv --enable-fpm --enable-zip --enable-mbstring && make -j 4 && make
install && cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf && sed -i "s/127.0.0.1/0.0.0.0/" /usr/local/php/
etc/php-fpm.conf && cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm
COPY php.ini /usr/local/php/etc
EXPOSE 9000
CMD /etc/init.d/php-fpm start && tail -F /var/log/messages
[root@iZwz92l6rbipfcgz6jol18Z lnmp]# cat docker-compose.yml
#版本 3
version: "3"
#服务
serviecs:
#服务名字
nginx:
#容器名字
hostname: nginx
#构建
build:
#指定当前文件下的nginx目录
context: ./nginx
#指定Dockerfile
dockerfile: Dockerfile
#容器服务80端口映射到宿主机80端口
ports:
- "80:80"
#连接到另一个php容器php-cgi服务
links:
- php:php-cgi
#指定数据卷当前目录wwwroot下
volumes:
- ./wwwroot:/usr/local/nginx/html
php:
hostname: php
build: ./php
#连接到另一个mysql容器
lines:
- mysql:mysql-db
volumes:
- ./wwwroot:/usr/local/nginx/html
mysql:
hostname: mysql
image: mysql:5.6
ports:
- "3306:3306":
volumes:
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/data:/varlib/mysql
# command: --character-set-server=utf8
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: wordpress
MYSQL_USER: user
MYSQL_PASSWORD: user123
标签:docker
原文地址:http://blog.51cto.com/3417581/2087950