dream0776
2016-04-30 11:51
浏览 88
已采纳

使用docker的多个nginx / php应用程序的体系结构

I've been running most of my apps on single nginx/php-fpm installation directly on vps. I've decided to try out docker, and have been playing with it for a week now. I've read everything possible and believe I understand its concepts.

But I cannot wrap my head around having so many instances of nginx, php and db.

One thing I settled with is that I want to have 1 db, so that's easy:

mariadb:
  image: mariadb:latest
  container_name: mariadb
  ports:
    - "127.0.0.1:3306:3306"
  restart: always
  environment:
    MYSQL_ROOT_PASSWORD: xxxxx
  volumes:
    - /srv/mysql:/var/lib/mysql

I also found nginx-proxy together with nginx-certs work like charm:

nginx-proxy:
  image: jwilder/nginx-proxy
  container_name: nginx-proxy
  ports:
    - "80:80"
    - "443:443"
  restart: always
  volumes:
    - /srv/certs:/etc/nginx/certs:ro
    - /var/run/docker.sock:/tmp/docker.sock:ro
    - ./vhost.d:/etc/nginx/vhost.d
    - /usr/share/nginx/html


nginx-certs:
  image: jrcs/letsencrypt-nginx-proxy-companion
  container_name: nginx-certs
  volumes:
    - /srv/certs:/etc/nginx/certs:rw
    - /var/run/docker.sock:/var/run/docker.sock:ro
  volumes_from:
    - nginx-proxy

This is all dandy. But how do I handle actual app containers?

I want to keep ram usage to minimum, so what is recommended:

  1. 1 php-fpm container with multiple volumes inside and multiple nginx servers
  2. 1 nginx server and multiple php-fpm containers?
  3. have 1 container per project and keep nginx/php-fpm inside that container
  4. X nginx containers + X php-fpm containers. X amount of apps.

Any ideas?

图片转代码服务由CSDN问答提供 功能建议

我一直在vps上运行单个nginx / php-fpm安装的大多数应用程序。 我决定尝试使用码头工,现在已经玩了一个星期了。 我已经阅读了所有可能的内容并相信我理解了它的概念。

但我无法理解有这么多nginx,php和db的实例。

我确定的一件事就是我想拥有1分贝,所以这很容易:

  mariadb:
 image:mariadb:latest 
 container_name:mariadb \  n端口:
  - “127.0.0.1:3306:3306"nn restart:always 
 environment:
 MYSQL_ROOT_PASSWORD:xxxxx 
卷:
  -  / srv / mysql:/ var / lib / mysql 
 <  / code>  
 
 

我还发现nginx-proxy和nginx-certs一样有魅力:

  nginx-proxy:
 image  :jwilder / nginx-proxy 
 container_name:nginx-proxy 
 ports:
  - “80:80”
  - “443:443”
 restart:always 
卷:
  -  / srv / certs:  / etc / nginx / certs:ro 
  -  /var/run/docker.sock:/tmp/docker.sock:ro
  -  ./vhost.d:/etc/nginx/vhost.d
  -  / usr  / share / nginx / html 
 
 
nginx-certs:
 image:jrcs / letsencrypt-nginx-proxy-companion 
 container_name:nginx-certs 
卷:
  -  / srv / cert  s:/ etc / nginx / certs:rw 
  -  /var/run/docker.sock:/var/run/docker.sock:ro
 volumes_from:
  -  nginx-proxy 
   
 
 

这都是花花公子。 但是我如何处理实际的应用程序容器?

我想将ram使用率保持在最低限度,因此建议:

  1. 1个内置多个卷的php-fpm容器和多个nginx服务器
  2. 1个nginx服务器和多个php-fpm容器?
  3. 每个项目有1个容器并保留nginx / php-fpm在那个容器里面
  4. X nginx容器+ X php-fpm容器。 X数量的应用程序。

    任何想法?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题