2

I have Graylog put in docker container using docker-compose with elasticSearch and MongoDB. Ofcourse when I configure it once on machine and run docker-compose again configuration stays. Unfortunately when I want to change machines (run on another environment), I need to do configuration again.

How can I persist a configuration of streams and inputs that after changing environment/machines I will not need to configure them again?

Fragment of 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
Piotr
  • 569
  • 6
  • 20

1 Answers1

-1

You could create a generic docker-compose file and use environment variables to configure the different addresses, ports etc that changes for each environment. Environment variables in docker compse files are written like ${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

And then you will have to create each referenced environment variable in each environment.

Link to docker-compose docs: Docker Compose environment variables

Stigsen
  • 1
  • 1