gpt4 book ai didi

docker - Linux和Windows上的Docker-Compose之间有区别吗?

转载 作者:行者123 更新时间:2023-12-03 01:19:19 28 4
gpt4 key购买 nike

我遇到了Linux和Windows之间的部署差异的问题。我有以下Docker-Compose文件:

version: '3'

services:

elasticsearch:

image: docker.elastic.co/elasticsearch/elasticsearch:6.3.0
ports:
- 9200:9200
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
environment:
discovery.type: single-node
cluster.routing.allocation.disk.threshold_enabled: "false"
networks:
logmetric:

kibana:
image: docker.elastic.co/kibana/kibana:6.3.0
ports:
- 5601:5601
networks:
logmetric:
depends_on:
- elasticsearch

influxdb:
image: influxdb
ports:
- 8086:8086
volumes:
# Data persistency
- influxdb_data:/var/lib/influxdb
networks:
logmetric:

grafana:
image: grafana/grafana
ports:
- 3000:3000
volumes:
# Data persistency
- grafana_data:/var/lib/grafana
networks:
logmetric:

volumes:
elasticsearch_data:
influxdb_data:
grafana_data:

networks:
logmetric:
driver: 'bridge'


当我在 Windows 上执行 Docker-Compose -f compose_logging.yaml up时,一切正常旋转,并且所有服务都在工作。 但是,如果我将这个yaml文件转移到我的linux计算机(CentOS 8)上并执行相同的命令,则,Kibana无法连接到 flex 搜索数据库。我收到错误:

kibana_1 | {"type":"log","@timestamp":"2020-04-03T21:41:42Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"} kibana_1 | {"type":"log","@timestamp":"2020-04-03T21:41:42Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}



如果我在linux机器(即elasticsearch数据库)上“curl http://localhost:9200”,则会得到响应。因此,我相信启动起来并在等待连接。响应:
{
"name" : "CQ7jdN0",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "swSAp0kUR7iQpqTpW3Iv_g",
"version" : {
"number" : "6.3.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "424e937",
"build_date" : "2018-06-11T23:38:03.357887Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

如果我在docker网络( docker inspect andy_logmetric)上进行检查,则会得到 LINUX 网络的以下信息:
[andy@Dev_Linux ~]$ docker inspect andy_logmetric
[
{
"Name": "andy_logmetric",
"Id": "1d6544f05915e1673c5f541bcfe024fc3ad3d445cba43f0109a4bbd1e9faf9a0",
"Created": "2020-04-03T15:59:24.036741117-04:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"091975207ec170c3c98223030add8f9b134f35b1aa05fd2016a31d985c73bc7f": {
"Name": "andy_elasticsearch_1",
"EndpointID": "b8263230459db25d873a79dff94e7d6b0a3cb8a2ed6bfff149559b54748e93cc",
"MacAddress": "02:42:ac:12:00:04",
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
},
"10a22cc7ef65897417f58e0928598066ad899f25d43e2429c903282f5e74cef2": {
"Name": "andy_kibana_1",
"EndpointID": "1f8998efd1c61a40b9876ffd6502f0ec371ec926b5cd1e7851bd6dd31074c1c5",
"MacAddress": "02:42:ac:12:00:05",
"IPv4Address": "172.18.0.5/16",
"IPv6Address": ""
},
"542d6b764b084d99895f89c881aaf6fdf42edf63494edcd233dd35445706e3fc": {
"Name": "andy_influxdb_1",
"EndpointID": "4247f8fcb961e75fab6662133df9eb012a70707757db5ea6c37d7812c018f520",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
},
"e6fead6035cdb7b60e81114f124fa87084b7eb6b92c9b3800e66072dbcc82ba3": {
"Name": "andy_grafana_1",
"EndpointID": "9a0c892237fe891ef6e714bf8292857c9e2d68ac0f6abd7a99eba6daf6971f3c",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "logmetric",
"com.docker.compose.project": "andy",
"com.docker.compose.version": "1.25.4"
}
}
]

对于 WINDOWS 网络,我得到以下信息:
PS C:\Users\Michael> docker inspect docker-composefiles_logmetric
[
{
"Name": "docker-composefiles_logmetric",
"Id": "d1bebbe4e73097fb6dcb4ab15750e2689e2e57da83e880b065063dcde055e576",
"Created": "2020-04-03T21:24:14.531822721Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"0820891e073e7e05cbcc7ab834cc599c640e6518bb36c848052b6a6c11b5c069": {
"Name": "docker-composefiles_grafana_1",
"EndpointID": "4e2c85709e89fd4b3bb609fc53eb4a4538b1fd93e51cfd73d8dc030d7707d6e3",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
},
"8ada45e8a940102fe3145dee290af2da06d46d8bd465411da48bddf18d22167a": {
"Name": "docker-composefiles_elasticsearch_1",
"EndpointID": "5cc9b924eb46a7bc1bc07d3985779a1e0bf9ac4012c12333d6cbb96e3f78af2d",
"MacAddress": "02:42:ac:12:00:04",
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
},
"902bec9dc51e542589a3da1f13648a3434bc2d10b6c5755adfa545d813032c18": {
"Name": "docker-composefiles_influxdb_1",
"EndpointID": "a0e5e49121616590260b04932b6943601f06dc3200564f9155ce2f2281625cf9",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"c054af26402fcbee5c9e727b8a3e8b009fd258734f060e1fc9dc19ade5f7f3fa": {
"Name": "docker-composefiles_kibana_1",
"EndpointID": "3f57dcaefde331cfa7bdc862f45a0dc95829cb89604b28347d8c452f0f60f396",
"MacAddress": "02:42:ac:12:00:05",
"IPv4Address": "172.18.0.5/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "logmetric",
"com.docker.compose.project": "docker-composefiles",
"com.docker.compose.version": "1.25.4"
}
}
]

转储这两个文件并运行比较只会产生明显的ID和项目名称不同。

如果我用Chrome按下kibana,则在Windows上一切正常。在linux kibana上,我进入一个禁用的登录屏幕,该屏幕显示您无法立即登录并查看日志。 (错误消息在上方)

网络看起来一样,但是Kibana无法在Linux上访问 flex 搜索数据库,但可以在Windows上访问。

linux计算机上的docker版本如下:
Docker version 19.03.8, build afacb8b
[andy@Dev_Linux ~]$ docker-compose --version
docker-compose version 1.25.4, build 8d51620a

Windows机器上的docker版本如下:
Docker version 19.03.8, build afacb8b
PS C:\Users\Michael> docker-compose --version
docker-compose version 1.25.4, build 8d51620a

我不知道还要找什么。是否对Linux环境中可能发生的事情有任何想法?

最佳答案

检查此链接:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-prerequisites

我记得在centos上遇到麋鹿问题,并且在主机上设置内核参数很有帮助。

Docker编写仅仅是docker命令本身上出现的python脚本,因此问题不在于此。事实很可能是,在Windows上您可能使用的是docker-machine,这是linux hyper-v vm,而在centos上则是真正的linux,因此有所不同。

您还可以检查docker log [container name]以查看elasticsearch在控制台上是否未显示任何警告。

您可以尝试的另一种检查方法是使用docker exec -it /bin/sh放入容器并ping其他容器。 Docker使用系统内部创建的网络,因此,如果网络中您的centos服务器位于与docker创建的子网相同的子网中,则主机路由机制可能会将数据包发送到“真实”网络,而不是在docker内部。

关于docker - Linux和Windows上的Docker-Compose之间有区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61021063/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com