我在多个地方都有类似此示例的代理设置。 https://medium.com/@airman604/getting-docker-to-work-with-a-proxy-server-fadec841194e,但想在一个容器(metricbeat)上指定完全不通过代理,因为它似乎使容器503服务不可用。
在docker-compose.yml文件中尝试使用此选项将其强制直接进入端口9200上的elasticsearch容器:
environment:
- HTTP_PROXY:http://es:9200
- http_proxy:http://es:9200
- HTTPS_PROXY:http://es:9200
- https_proxy:http://es:9200
- HTTP_PROXY=http://es:9200
- http_proxy=http://es:9200
- HTTPS_PROXY=http://es:9200
- https_proxy=http://es:9200
但是后来我收到了400个错误的请求。
2020-02-19T16:07:59.139Z ERROR instance/beat.go:906 Exiting: Error importing Kibana dashboards: fail to create the Elasticsearch loader: Error creating Elasticsearch client: Couldn't connect to any of the configured Elasticsearch hosts. Errors: [Error connection to Elasticsearch http://es:9200: 400 Bad Request: {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"},"status":400}]
Exiting: Error importing Kibana dashboards: fail to create the Elasticsearch loader: Error creating Elasticsearch client: Couldn't connect to any of the configured Elasticsearch hosts. Errors: [Error connection to Elasticsearch http://es:9200: 400 Bad Request: {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: type is missing;"},"status":400}]
但是在docker容器中,它既混合了我的变量,也混合了主机环境变量:
"Env": [
"HTTP_PROXY=http://es:9200",
"http_proxy=http://es:9200",
"HTTPS_PROXY=http://es:9200",
"https_proxy=http://es:9200",
"NO_PROXY=localhost,127.0.0.1,::1,*.global.biz,11.*",
"no_proxy=localhost,127.0.0.1,::1,*.global.biz,11.*",
"HTTP_PROXY:http://es:9200",
"http_proxy:http://es:9200",
"HTTPS_PROXY:http://es:9200",
"https_proxy:http://es:9200",
"PATH=/usr/share/metricbeat:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ELASTIC_CONTAINER=true"
],