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 php-fpm container with multiple volumes inside and multiple nginx servers
- 1 nginx server and multiple php-fpm containers?
- have 1 container per project and keep nginx/php-fpm inside that container
- X nginx containers + X php-fpm containers. X amount of apps.
Any ideas?