泊坞码头之后的理由构成“链接”订购 [英] rationale behind docker compose "links" order
问题描述
Redis将从远程位置收到日志,并将其转发给Logstash,然后将其转换为常规的Elasticsearch,Kibana。
在docker-compose.yml ,我对链接的顺序感到困惑
弹性搜索链接到没有人,而logstash链接到redis和elasticsearch
elasticsearch:
redis:
logstash:
links:
- elasticsearch
- redis
kibana:
链接:
- 弹性搜索
这个订单是否正确?选择连接方向的理由是什么?
为什么我们不说弹性搜索链接到logstash?
而不是使用Legacy容器链接方法您可以使用Docker用户定义的网络。基本上,您可以为服务定义一个网络,然后在docker-compose文件中指出您希望容器在该网络上运行。如果您的容器都运行在同一个网络上,他们可以通过其容器名称进行访问(DNS记录自动添加)。
1):创建用户定义的网络< h3>
docker network create pocnet
2):更新docker -
您要将容器添加到您刚创建的网络中。您的docker-compose文件将显示以下内容:
版本:'2'
服务:
elasticsearch:
image:elasticsearch
container_name:elasticsearch
ports:
- {your:ports}
networks:
- pocnet
redis:
image:redis
container_name:redis
ports:
- {your:ports}
networks :
- pocnet
logstash:
image:logstash
container_name:logstash
ports:
- {your:ports}
网络:
- pocnet
kibana:
image:kibana
container_name:kibana
ports:
- 5601:5601
网络:
- pocnet
网络:
pocnet:
外部:真
3):启动服务
docker-compose up
注意:你可能想要打开一个新的shell窗口运行步骤4。
4):测试
进入Kibana容器看看你是否可以ping弹性搜索容器。
your__Machine:/ docker exec -it kibana bash
kibana @ 123456:/#ping elasticsearch
I have a Redis - Elasticsearch - Logstash - Kibana stack in docker which I am orchestrating using docker compose. Redis will receive the logs from a remote location, will forward them to Logstash, and then the customary Elasticsearch, Kibana.
In the docker-compose.yml, I am confused about the order of "links"
Elasticsearch links to no one while logstash links to both redis and elasticsearch
elasticsearch:
redis:
logstash:
links:
- elasticsearch
- redis
kibana:
links:
- elasticsearch
Is this order correct? What is the rational behind choosing the "link" direction. Why don't we say, elasticsearch is linked to logstash?
Instead of using the Legacy container linking method, you could instead use Docker user defined networks. Basically you can define a network for your services and then indicate in the docker-compose file that you want the container to run on that network. If your containers all run on the same network they can access each other via their container name (DNS records are added automatically).
1) : Create User Defined Network
docker network create pocnet
2) : Update docker-compose file
You want to add your containers to the network you just created. Your docker-compose file would look something along the lines of this :
version: '2'
services:
elasticsearch:
image: elasticsearch
container_name: elasticsearch
ports:
- "{your:ports}"
networks:
- pocnet
redis:
image: redis
container_name: redis
ports:
- "{your:ports}"
networks:
- pocnet
logstash:
image: logstash
container_name: logstash
ports:
- "{your:ports}"
networks:
- pocnet
kibana:
image: kibana
container_name: kibana
ports:
- "5601:5601"
networks:
- pocnet
networks:
pocnet:
external: true
3) : Start Services
docker-compose up
note : you might want to open a new shell window to run step 4.
4) : Test
Go into the Kibana container and see if you can ping the elasticsearch container.
your__Machine:/ docker exec -it kibana bash
kibana@123456:/# ping elasticsearch
这篇关于泊坞码头之后的理由构成“链接”订购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!