I'm putting together a docker-compose.yml
file to run the multiple services for a project I'm working on. This project has a Magento and Wordpress website residing under the same domain, with that "same domain" aspect requiring a very simple nginx container to route requests to either service.
So I have this architected as 4 containers (visualisation):
- A "magento" container, using an in-house project-specific image.
- A "wordpress" container, using an in-house project-specific image.
- A "db" container running
mysql:5.6
, with the init db dumps mounted at/docker-entrypoint-initdb.d
. - A "router" container running
nginx:alpine
with a custom config mounted at/etc/nginx/nginx.conf
. This functions as a reverse-proxy with two location directives set up.location /
routes to "magento", andlocation /blog
routes to "wordpress".
I want to keep things simple and avoid building unnecessary custom images, but in the context of the "router" I'm not sure what I'm doing is the best approach, or if that would be better off as a project-specific image.
I'm leaning toward my current approach of mounting a custom config into the nginx:alpine
container, because the configuration is specific to the stack that's running – it wouldn't make sense as a single standalone container.
So the two methods, without a custom image we have the following in docker-compose.yml
router:
image: nginx:alpine
networks:
- projectnet
ports:
- "80:80"
volumes:
- "./router/nginx.conf:/etc/nginx/nginx.conf"
Otherwise, we have a Dockerfile
containing the following, as I've seen suggested across the internet and in other StackOverflow responses.
FROM nginx:alpine
ADD nginx.conf /etc/nginx/
Does anybody have arguments for/against either approach?