I have a docker-compose
setup for development, and I need to replicate the same file for production or staging.
Currently, aside from volumes
ports
and environment
I am not quite sure what settings "may need" to be changed for production/environment.
To clarify:
volumes
, because I usually mount a USB drive to my docker container ex: d:/var/www
ports
is, because there may be other services that use port 80 on my local machine, so I may need to change that. environment
is of course, different for prod/dev .. (mainly authentication and database access)Any more tips would be nice to know.
The exact list would depend on your environment/ops team requirements, but this is what seems to be useful besides ports/existing volumes:
Networks
The default network might not work for your prod environment. As an example, your ops team might decide to put nginx/php-fpm/mariadb on different networks like in the following example (https://docs.docker.com/compose/networking/#specify-custom-networks) or even use a pre-existing network
Mysql configs
They usually reside in a separate dir i.e. /etc/my.cnf
and /etc/my.cnf.d
.
These configs are likely to be different between prod/dev.
Can’t see it in your volumes paths
Php-fpm7
Haven’t worked with php-fpm7
, but in php-fpm5
it also had a different folder with config files (/etc/php-fpm.conf
and /etc/php-fpm.d
) that is missing in your volumes. These files are also likely to differ once your handle even a moderate load (you’ll need to configure number of workers/timeouts etc)
Nginx
Same as for php-fpm
, ssl settings/hostnames/domains configurations are likely to be different
Logging
Think on what logging driver might fit your needs best. From here:
Docker includes multiple logging mechanisms to help you get information from running containers and services. These mechanisms are called logging drivers.
You can easily configure it in docker-compose, here's an example bring up a dedicated fluentd
container for logging:
version: "3"
services:
randolog:
image: golang
command: go run /usr/src/randolog/main.go
volumes:
- ./randolog/:/usr/src/randolog/
logging:
driver: fluentd
options:
fluentd-address: "localhost:24224"
tag: "docker.{{.ID}}"
fluentd:
build:
context: ./fluentd/
ports:
- "24224:24224"
- "24224:24224/udp"