I am compiling a docker-compose.yml to run several services for the project I'm working on. This project has a Magento and Wordpress website located in the same domain, with that aspect of the "same domain" that requires a very simple nginx container to route requests to any service.
So, I have it archived as 4 containers ( visualization ):
- The container is purple using its own image for the project.
- Content "wordpress" using a proprietary image specific to the project.
- The "db" container with
mysql:5.6 , with init db /docker-entrypoint-initdb.d set in /docker-entrypoint-initdb.d . - The router container is running
nginx:alpine with a custom configuration installed in /etc/nginx/nginx.conf . This works as a reverse proxy with two location settings. location / routes to purple and location /blog routes to wordpress.
I want everything to be simple and not create unnecessary custom images, but in the context of the “router” I’m not sure what I’m doing is the best approach or if it will be better than the project-specific image.
I am inclined to my current approach to creating a custom configuration in the nginx:alpine container, because the configuration is specific to the executable stack - it does not make sense as a separate standalone container.
Thus, two methods without a custom image have the following meanings 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 have seen, offered over the Internet and in other StackOverflow answers.
FROM nginx:alpine ADD nginx.conf /etc/nginx/
Does anyone have any arguments for / against any approach?
source share