docker-compos
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker-compos相关的知识,希望对你有一定的参考价值。
[[email protected] lnmp]# tree ..
├── docker-compose.yml
├── mysql
│?? └── conf
│?? └── my.cnf
├── nginx
│?? ├── Dockerfile
│?? ├── nginx-1.12.2.tar.gz
│?? └── nginx.conf
├── php
│?? ├── Dockerfile
│?? ├── php-5.6.34.tar.gz
│?? └── php.ini
└── wwwroot
[[email protected] 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;"]
[[email protected] 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
[[email protected] 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-compos的主要内容,如果未能解决你的问题,请参考以下文章