我正在尝试将我需要使用的所有弹性服务进行篡改。停靠-组合文件如下所示
version: '3'
services:
redis:
build: ./docker/redis
postgresql:
build: ./docker/postgresql
ports:
- "5433:5432"
env_file:
- .env
graphql:
build: .
command: npm run start
volumes:
- ./logs/:/usr/app/logs/
ports:
- "3000:3000"
env_file:
- .env
depends_on:
- "redis"
- "postgresql"
links:
- "redis"
- "postgresql"
elasticsearch:
build: ./docker/elasticsearch
container_name: elasticsearch
networks:
- elastic
ports:
- "9200:9200"
depends_on:
- "graphql"
links:
- "kibana"
kibana:
build: ./docker/kibana
container_name: kibana
ports:
- "5601:5601"
depends_on:
- "graphql"
networks:
- elastic
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
metricbeat:
build: ./docker/metricbeat
depends_on:
- "graphql"
- "elasticsearch"
- "kibana"
volumes:
- /proc:/hostfs/proc:ro
- /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
- /:/hostfs:ro
networks:
- elastic
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
command:
- "-system.hostfs=/hostfs"
packetbeat:
build: ./docker/packetbeat
depends_on:
- "graphql"
- "elasticsearch"
- "kibana"
cap_add:
- NET_ADMIN
networks:
- elastic
environment:
- ELASTICSEARCH_URL=http://127.0.0.1:9200
logstash:
build: ./docker/logstash
ports:
- "9600:9600"
volumes:
- ./logs:/usr/logs
depends_on:
- "graphql"
- "elasticsearch"
- "kibana"
networks:
- elastic
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
networks:
elastic:
driver: bridge现在一切都运行得很好,但问题是,Packet节拍只是在它自己的码头容器中捕获网络。在弹性文档引用- https://www.elastic.co/guide/en/beats/packetbeat/master/running-on-docker.html中,它说我需要启用‘主机’网络,以便将所有原始和到达的网络捕获到物理主机。但是,由于我已经将网络配置为-elastic,所以无法向packet节拍添加额外的主机网络接口。如果删除-elastic网络并添加-host网络,则无法连接到elasticsearch,因为DNS elasticsearch不再存在于不同的网络中。我怎样才能克服这个问题?
发布于 2018-08-27 09:51:55
这是一个很常见的问题,因为码头的隔离会妨碍你的工作。例如,当使用Prometheus node_exporter收集主机的度量时也会发生同样的情况,如果在没有访问主机网络的容器中运行,这也是非常无用的。
正如您已经提到的,不可能同时使用network_mode: host和networks。因此,对于您的用例,您可以使用主机网络运行packet节拍容器,而不是将其附加到码头网络。因此,您不再能够通过http://elasticsearch:9200将其连接到elasticsearch实例,因此需要将此配置值替换为http://your-host-ip:9200,而您已经在elasticsearch服务中将其配置为映射端口。可能的话,http://127.0.0.1在与network_mode: host一起运行时也可以工作,因为这应该是主机网络中的localhost,因此也就是映射elasticsearch端口的主机。
https://stackoverflow.com/questions/51871798
复制相似问题