我使用带有elasticSearch和MongoDB的docker-compose将Graylog放入docker容器中。当我在机器上配置一次并运行docker-compose时,配置保持不变。不幸的是,当我想要更换机器(在另一个环境中运行)时,我需要再次进行配置。
如何在更改环境/机器后保持流和输入的配置,我不需要再次配置它们?
docker-compose片段:
# Graylog: https://hub.docker.com/r/graylog/graylog/
graylog:
image: graylog/graylog:2.4.0-1
environment:
# CHANGE ME!
- GRAYLOG_PASSWORD_SECRET=somepasswordpepper
# Password: admin
- GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
- GRAYLOG_WEB_ENDPOINT_URI=http://127.0.0.1:9000/api
links:
- mongodb:mongo
- elasticsearch
depends_on:
- mongodb
- elasticsearch
ports:
# Graylog web interface and REST API
- 9000:9000
# Graylog web interface and REST API
# Syslog TCP
- 514:514
# Syslog UDP
- 514:514/udp
# GELF TCP
- 12201:12201
# GELF UDP
- 12201:12201/udp
答案 0 :(得分:-1)
您可以创建一个通用的docker-compose文件,并使用环境变量来配置为每个环境更改的不同地址,端口等。 docker compse文件中的环境变量类似于$ {this}
# Graylog: https://hub.docker.com/r/graylog/graylog/
graylog:
image: graylog/graylog:2.4.0-1
environment:
# CHANGE ME!
- GRAYLOG_PASSWORD_SECRET=${GRAYLOG_PASSWORD_SECRET}
# Password: ${GRAYLOG_PASSWORD}
- GRAYLOG_ROOT_PASSWORD_SHA2=${GRAYLOG_SHA}
- GRAYLOG_WEB_ENDPOINT_URI=${GRAYLOG_ENDPOINT}
links:
- mongodb:mongo
- elasticsearch
depends_on:
- mongodb
- elasticsearch
ports:
# Graylog web interface and REST API
- 9000:9000
# Graylog web interface and REST API
# Syslog TCP
- 514:514
# Syslog UDP
- 514:514/udp
# GELF TCP
- 12201:12201
# GELF UDP
- 12201:12201/udp
然后,您必须在每个环境中创建每个引用的环境变量。
链接到docker-compose docs: Docker Compose environment variables