问题描述
我有一个 docker-compose
设置用于开发,我需要复制相同的文件进行生产或暂存。
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.
要澄清一下:
- 我必须更改
卷
,因为我通常将USB驱动器安装到我的Docker容器中,例如:d:/ var / www
-
端口
的问题是,因为可能还有其他服务在我的本地计算机上使用端口80,所以我可能需要更改它。 -
环境
当然对于prod / dev ..(主要是身份验证和数据库访问)有所不同
- I have to change
volumes
, because I usually mount a USB drive to my docker container ex:d:/var/www
- The issue with
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.
推荐答案
确切的列表取决于您的环境/ ops团队的要求,但这似乎对端口/现有端口很有用。数量:
The exact list would depend on your environment/ops team requirements, but this is what seems to be useful besides ports/existing volumes:
网络
默认网络可能不适用于您的产品环境。
例如,您的运营团队可能决定将nginx / php-fpm / mariadb放置在不同的网络上,例如以下示例(),甚至使用预先存在的网络
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配置
它们通常位于单独的目录中,即 /etc/my.cnf
和 /etc/my.cnf.d
。
这些配置在prod / dev之间可能有所不同。
在卷路径中看不到
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
还没有使用 php-fpm7
,但是在 php-fpm5
中也有一个不同的文件夹,缺少的配置文件( /etc/php-fpm.conf
和 /etc/php-fpm.d
)在您的书卷中。这些文件也可能会有所不同,即使您的负载适中(您需要配置worker / timeout的数量等)
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
与 php-fpm
相同,ssl设置/主机名/域配置可能不同
Same as for php-fpm
, ssl settings/hostnames/domains configurations are likely to be different
记录
请考虑哪种记录驱动程序可能最适合您的需求。
来自:
Think on what logging driver might fit your needs best.From here:
您可以在docker-compose中轻松配置它,这里有一个示例专用的 fluentd
容器进行记录:
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"
这篇关于为生产和开发创建单独的docker-compose配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!