gpt4 book ai didi

docker - 使用 PHP 的 Elasticsearch 没有相互链接

转载 作者:行者123 更新时间:2023-12-02 21:11:05 26 4
gpt4 key购买 nike

这是我的 docker 撰写:

version: "2"
services:
mongodb:
container_name: "elastic_backend_mongodb"
restart: "always"
image: "mongo:latest"
volumes:
- "./data/db/:/data/db"
ports:
- "27017:27017"
command: --storageEngine wiredTiger
networks:
- "elastic_backend"
php:
build: ./develop
container_name: "elastic_backend_php"
restart: "always"
environment:
PHP_IDE_CONFIG: serverName=elastic_backend
depends_on:
- "mongodb"
- "db"
- "elasticsearch"
expose:
- "9000"
volumes:
- "../.:/var/www/html"
networks:
- "elastic_backend"
nginx:
image: "nginx:latest"
container_name: "elastic_backend_nginx"
restart: "always"
volumes:
- "./nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro"
- "./nginx/conf.d:/etc/nginx/conf.d:ro"
ports:
- "80:80"
volumes_from:
- "php"
networks:
- "elastic_backend"
db:
container_name: "elastic_backend_mysql"
restart: "always"
image: "mysql:5.7"
command: --max_allowed_packet=32505856
environment:
MYSQL_ROOT_PASSWORD: "asd"
MYSQL_DATABASE: "elastic_backend"
ports:
- "3306:3306"
volumes:
- "./mysql:/var/lib/mysql"
networks:
- "elastic_backend"
elasticsearch:
container_name: "elastic_backend_es"
image: elasticsearch:6.5.4
environment:
- discovery.type=single-node
ports:
- "9200:9200"
- "9300:9300"
networks:
elastic_backend:

因此,除了 php 容器无法 ping elasticsearch 容器外,一切正常。 db 和 mongodb 容器可以从 php 容器中很好地 ping 通。我还尝试对 docker 使用“链接”和模拟指令,但没有任何运气。
那么我做错了什么?

我能够从主机(macos)获取 Elasticsearch 的其余接口(interface):
{
"name": "cDsdqXL",
"cluster_name": "docker-cluster",
"cluster_uuid": "010ETY4zT_C8XJu1IfON-g",
"version": {
"number": "6.5.4",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "d2ef93d",
"build_date": "2018-12-17T21:17:40.758843Z",
"build_snapshot": false,
"lucene_version": "7.5.0",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}

最佳答案

PHP 容器无法在此处访问 elasticsearch 容器,因为 elasticsearch服务未连接到 elastic_backend网络。将此添加到 elasticsearch 下服务。

    networks:
- "elastic_backend"

关于docker - 使用 PHP 的 Elasticsearch 没有相互链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54521014/

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