# 拉取镜像
docker pull elasticsearch:7.12.0
docker pull graylog/graylog:4.3.6
docker pull mongo:4.2# 创建网络
docker network create mynetwork# 配置三个文件,es,mogo,graylog
vi dockercompose-es.yml
version: '3'
services:elasticsearch:image: elasticsearch:7.12.0container_name: elasticsearch # graylog内默认连接名为elasticsearch,所以不建议改environment:- "TAKE_FILE_OWNERSHIP=true"- "discovery.type=single-node"- "ES_JAVA_OPTS=-Xms512m -Xmx512m"volumes:- /etc/localtime:/etc/localtime- /home/mycontainers/es/data:/usr/share/elasticsearch/data- /home/mycontainers/es/logs:/usr/share/elasticsearch/logsulimits: # 调整 ulimits 以及 nproceditmemlock:soft: -1hard: -1deploy:resources:limits:memory: 1g # 限制使用内存ports:- 9200:9200- 9300:9300network_mode: mynetworkvi dockercompose-mogo.yml
version: '3'
services:mongo:image: mongo:4.2container_name: mongo # graylog内默认连接名为mongo,所以这个不建议改restart: alwaysvolumes:- /etc/localtime:/etc/localtime- /home/mycontainers/mongo/data:/data/dbports:- 27017:27017network_mode: mynetworkvi dockercompose-graylog.yml
version: '3'
services:graylog:image: graylog/graylog:4.3.6container_name: graylogenvironment:# echo -n "Enter Password: " && head -1 < /dev/stdin | tr -d '\n' | sha256sum | cut -d " " -f1- GRAYLOG_PASSWORD_SECRET=somepasswordpepper- GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918- GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9009/- GARYLOG_ELASTICSEARCH_HOSTS=http://elasticsearch:9200 # 链接es,这里是容器间通讯,所以写容器名- GRAYLOG_MONGODB_URI=mongodb://mongo:27017/graylog # 同上# volumes:# - /home/mycontainers/graylog/config/graylog.conf:/usr/share/graylog/data/config/graylog.conf # 指定配置文件,用于修改时区network_mode: mynetworkrestart: alwaysports:- 9009:9000# Syslog TCP- 1514:1514# Syslog UDP- 1514:1514/udp# GELF TCP- 12201:12201# GELF UDP- 12201:12201/udp# 启动
docker-compose -f dockercompose-es.yml up
docker-compose -f dockercompose-mogo.yml up
docker-compose -f dockercompose-graylog.yml up# 测试访问
http://192.168.5.10:9009/
账号密码:admin : admin