问题描述
我正在尝试在docker上运行弹性搜索我为与mysql容器连接的Rails应用程序构建了一个容器我想将此Rails容器与弹性容器连接但是我得到这个错误
I'm trying to run elastic search on docker I build a container for rails app connected with mysql containerI want to connect this rails container with the elastic containerbut I get this error
无法打开与localhost:9200的TCP连接(无法分配请求的地址-"localhost"端口9200的connect(2))
当我运行docker-compose up时这些网址可以正常工作 http://localhost:3000/
when I run docker-compose up these urls work finehttp://localhost:3000/
但是我在这个网址上遇到了这个错误 http://localhost:3000/messages
but I got that error with this url http://localhost:3000/messages
无法打开与localhost:9200的TCP连接(无法分配请求的地址-"localhost"端口9200的connect(2))
我想从此网址获得回复 http://localhost:3000/messages
I want to get a response from this url http://localhost:3000/messages
如何打开端口 9200 ??????????????
how can I open port 9200 ??????????????
这是我的docker-compose.yml文件
this my docker-compose.yml file
version: '2'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: chat_system
MYSQL_USER: appuser
MYSQL_PASSWORD: password
ports:
- "3307:3306"
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.0
environment:
TAKE_FILE_OWNERSHIP: "true"
network.host: "0.0.0.0"
http.port: "9200"
transport.host: localhost
transport.tcp.port: "9300"
xpack.ml.enabled: "false"
# volumes:
# - ./.data/elastic:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
ulimits:
nofile:
soft: "65536"
hard: "65536"
app:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- ".:/chat_system"
ports:
- "3000:3000"
depends_on:
- db
- elastic
links:
- db
- elastic
environment:
DB_USER: root
DB_NAME: chat_system
DB_PASSWORD: password
DB_HOST: db
ELASTIC_HOST: "localhost"
ELASTIC_PORT: "9200"
我运行此命令以获取弹性日志
I run this command to get elastic logs
sudo docker-compose logs elastic
我明白了
Attaching to docker_chat_elastic_1
elastic_1 | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
elastic_1 | [2019-09-24T17:58:29,261][INFO ][o.e.n.Node ] [] initializing ...
elastic_1 | [2019-09-24T17:58:29,722][INFO ][o.e.e.NodeEnvironment ] [WwjX-hI] using [1] data paths, mounts [[/ (overlay)]], net usable_space [735.2gb], net total_space [895.5gb], types [overlay]
elastic_1 | [2019-09-24T17:58:29,723][INFO ][o.e.e.NodeEnvironment ] [WwjX-hI] heap size [989.8mb], compressed ordinary object pointers [true]
elastic_1 | [2019-09-24T17:58:29,729][INFO ][o.e.n.Node ] [WwjX-hI] node name derived from node ID [WwjX-hIPSZ-7L9XS1bYQFA]; set [node.name] to override
elastic_1 | [2019-09-24T17:58:29,730][INFO ][o.e.n.Node ] [WwjX-hI] version[6.4.0], pid[1], build[default/tar/595516e/2018-08-17T23:18:47.308994Z], OS[Linux/4.4.0-142-generic/amd64], JVM["Oracle Corporation"/OpenJDK 64-Bit Server VM/10.0.2/10.0.2+13]
elastic_1 | [2019-09-24T17:58:29,731][INFO ][o.e.n.Node ] [WwjX-hI] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.arEsgr84, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -XX:UseAVX=2, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
elastic_1 | [2019-09-24T17:58:31,488][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [aggs-matrix-stats]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [analysis-common]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [ingest-common]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [lang-expression]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [lang-mustache]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [lang-painless]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [mapper-extras]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [parent-join]
elastic_1 | [2019-09-24T17:58:31,489][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [percolator]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [rank-eval]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [reindex]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [repository-url]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [transport-netty4]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [tribe]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-core]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-deprecation]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-graph]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-logstash]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-ml]
elastic_1 | [2019-09-24T17:58:31,490][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-monitoring]
elastic_1 | [2019-09-24T17:58:31,491][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-rollup]
elastic_1 | [2019-09-24T17:58:31,491][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-security]
elastic_1 | [2019-09-24T17:58:31,491][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-sql]
elastic_1 | [2019-09-24T17:58:31,491][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-upgrade]
elastic_1 | [2019-09-24T17:58:31,491][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-watcher]
elastic_1 | [2019-09-24T17:58:31,492][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded plugin [ingest-geoip]
elastic_1 | [2019-09-24T17:58:31,492][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded plugin [ingest-user-agent]
elastic_1 | [2019-09-24T17:58:33,514][WARN ][o.e.d.s.ScriptModule ] Script: returning default values for missing document values is deprecated. Set system property '-Des.scripting.exception_for_missing_value=true' to make behaviour compatible with future major versions.
elastic_1 | [2019-09-24T17:58:35,286][INFO ][o.e.x.s.a.s.FileRolesStore] [WwjX-hI] parsed [0] roles from file [/usr/share/elasticsearch/config/roles.yml]
elastic_1 | [2019-09-24T17:58:36,476][INFO ][o.e.d.DiscoveryModule ] [WwjX-hI] using discovery type [zen]
elastic_1 | [2019-09-24T17:58:37,104][INFO ][o.e.n.Node ] [WwjX-hI] initialized
elastic_1 | [2019-09-24T17:58:37,105][INFO ][o.e.n.Node ] [WwjX-hI] starting ...
elastic_1 | [2019-09-24T17:58:37,256][INFO ][o.e.t.TransportService ] [WwjX-hI] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
elastic_1 | [2019-09-24T17:58:40,338][INFO ][o.e.c.s.MasterService ] [WwjX-hI] zen-disco-elected-as-master ([0] nodes joined)[, ], reason: new_master {WwjX-hI}{WwjX-hIPSZ-7L9XS1bYQFA}{iaR_00fyTMuqfMiCpiq1UQ}{localhost}{127.0.0.1:9300}{xpack.installed=true}
elastic_1 | [2019-09-24T17:58:40,343][INFO ][o.e.c.s.ClusterApplierService] [WwjX-hI] new_master {WwjX-hI}{WwjX-hIPSZ-7L9XS1bYQFA}{iaR_00fyTMuqfMiCpiq1UQ}{localhost}{127.0.0.1:9300}{xpack.installed=true}, reason: apply cluster state (from master [master {WwjX-hI}{WwjX-hIPSZ-7L9XS1bYQFA}{iaR_00fyTMuqfMiCpiq1UQ}{localhost}{127.0.0.1:9300}{xpack.installed=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)[, ]]])
elastic_1 | [2019-09-24T17:58:40,359][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [WwjX-hI] publish_address {172.18.0.2:9200}, bound_addresses {0.0.0.0:9200}
elastic_1 | [2019-09-24T17:58:40,359][INFO ][o.e.n.Node ] [WwjX-hI] started
elastic_1 | [2019-09-24T17:58:40,672][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [WwjX-hI] Failed to clear cache for realms [[]]
elastic_1 | [2019-09-24T17:58:40,751][INFO ][o.e.g.GatewayService ] [WwjX-hI] recovered [0] indices into cluster_state
elastic_1 | [2019-09-24T17:58:42,283][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.watch-history-9] for index patterns [.watcher-history-9*]
elastic_1 | [2019-09-24T17:58:42,437][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.watches] for index patterns [.watches*]
elastic_1 | [2019-09-24T17:58:42,665][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.triggered_watches] for index patterns [.triggered_watches*]
elastic_1 | [2019-09-24T17:58:42,859][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-6-*]
elastic_1 | [2019-09-24T17:58:43,045][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.monitoring-es] for index patterns [.monitoring-es-6-*]
elastic_1 | [2019-09-24T17:58:43,305][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.monitoring-alerts] for index patterns [.monitoring-alerts-6]
elastic_1 | [2019-09-24T17:58:44,163][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.monitoring-beats] for index patterns [.monitoring-beats-6-*]
elastic_1 | [2019-09-24T17:58:44,422][INFO ][o.e.c.m.MetaDataIndexTemplateService] [WwjX-hI] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-6-*]
elastic_1 | [2019-09-24T17:58:45,050][INFO ][o.e.l.LicenseService ] [WwjX-hI] license [9f6ac6c0-620a-4b71-b3e7-da5bb37b8337] mode [basic] - valid
elastic_1 | [2019-09-24T18:00:15,514][INFO ][o.e.n.Node ] [WwjX-hI] stopping ...
elastic_1 | [2019-09-24T18:00:15,525][INFO ][o.e.x.w.WatcherService ] [WwjX-hI] stopping watch service, reason [shutdown initiated]
elastic_1 | [2019-09-24T18:00:15,764][INFO ][o.e.n.Node ] [WwjX-hI] stopped
elastic_1 | [2019-09-24T18:00:15,764][INFO ][o.e.n.Node ] [WwjX-hI] closing ...
elastic_1 | [2019-09-24T18:00:15,770][INFO ][o.e.n.Node ] [WwjX-hI] closed
elastic_1 | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
elastic_1 | [2019-09-24T18:00:28,430][INFO ][o.e.n.Node ] [] initializing ...
elastic_1 | [2019-09-24T18:00:28,776][INFO ][o.e.e.NodeEnvironment ] [WwjX-hI] using [1] data paths, mounts [[/ (overlay)]], net usable_space [735.1gb], net total_space [895.5gb], types [overlay]
elastic_1 | [2019-09-24T18:00:28,777][INFO ][o.e.e.NodeEnvironment ] [WwjX-hI] heap size [989.8mb], compressed ordinary object pointers [true]
elastic_1 | [2019-09-24T18:00:28,782][INFO ][o.e.n.Node ] [WwjX-hI] node name derived from node ID [WwjX-hIPSZ-7L9XS1bYQFA]; set [node.name] to override
elastic_1 | [2019-09-24T18:00:28,783][INFO ][o.e.n.Node ] [WwjX-hI] version[6.4.0], pid[1], build[default/tar/595516e/2018-08-17T23:18:47.308994Z], OS[Linux/4.4.0-142-generic/amd64], JVM["Oracle Corporation"/OpenJDK 64-Bit Server VM/10.0.2/10.0.2+13]
elastic_1 | [2019-09-24T18:00:28,783][INFO ][o.e.n.Node ] [WwjX-hI] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.wSQUCcFj, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -XX:UseAVX=2, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
elastic_1 | [2019-09-24T18:00:30,057][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [aggs-matrix-stats]
elastic_1 | [2019-09-24T18:00:30,057][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [analysis-common]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [ingest-common]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [lang-expression]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [lang-mustache]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [lang-painless]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [mapper-extras]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [parent-join]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [percolator]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [rank-eval]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [reindex]
elastic_1 | [2019-09-24T18:00:30,058][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [repository-url]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [transport-netty4]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [tribe]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-core]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-deprecation]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-graph]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-logstash]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-ml]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-monitoring]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-rollup]
elastic_1 | [2019-09-24T18:00:30,059][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-security]
elastic_1 | [2019-09-24T18:00:30,060][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-sql]
elastic_1 | [2019-09-24T18:00:30,060][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-upgrade]
elastic_1 | [2019-09-24T18:00:30,060][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded module [x-pack-watcher]
elastic_1 | [2019-09-24T18:00:30,060][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded plugin [ingest-geoip]
elastic_1 | [2019-09-24T18:00:30,060][INFO ][o.e.p.PluginsService ] [WwjX-hI] loaded plugin [ingest-user-agent]
elastic_1 | [2019-09-24T18:00:31,792][WARN ][o.e.d.s.ScriptModule ] Script: returning default values for missing document values is deprecated. Set system property '-Des.scripting.exception_for_missing_value=true' to make behaviour compatible with future major versions.
elastic_1 | [2019-09-24T18:00:33,335][INFO ][o.e.x.s.a.s.FileRolesStore] [WwjX-hI] parsed [0] roles from file [/usr/share/elasticsearch/config/roles.yml]
elastic_1 | [2019-09-24T18:00:34,159][INFO ][o.e.d.DiscoveryModule ] [WwjX-hI] using discovery type [zen]
elastic_1 | [2019-09-24T18:00:34,790][INFO ][o.e.n.Node ] [WwjX-hI] initialized
elastic_1 | [2019-09-24T18:00:34,790][INFO ][o.e.n.Node ] [WwjX-hI] starting ...
elastic_1 | [2019-09-24T18:00:34,927][INFO ][o.e.t.TransportService ] [WwjX-hI] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}
elastic_1 | [2019-09-24T18:00:38,001][INFO ][o.e.c.s.MasterService ] [WwjX-hI] zen-disco-elected-as-master ([0] nodes joined)[, ], reason: new_master {WwjX-hI}{WwjX-hIPSZ-7L9XS1bYQFA}{CzEAmK5jRsOh6lrRagMi_Q}{localhost}{127.0.0.1:9300}{xpack.installed=true}
elastic_1 | [2019-09-24T18:00:38,005][INFO ][o.e.c.s.ClusterApplierService] [WwjX-hI] new_master {WwjX-hI}{WwjX-hIPSZ-7L9XS1bYQFA}{CzEAmK5jRsOh6lrRagMi_Q}{localhost}{127.0.0.1:9300}{xpack.installed=true}, reason: apply cluster state (from master [master {WwjX-hI}{WwjX-hIPSZ-7L9XS1bYQFA}{CzEAmK5jRsOh6lrRagMi_Q}{localhost}{127.0.0.1:9300}{xpack.installed=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)[, ]]])
elastic_1 | [2019-09-24T18:00:38,023][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [WwjX-hI] publish_address {172.18.0.3:9200}, bound_addresses {0.0.0.0:9200}
elastic_1 | [2019-09-24T18:00:38,023][INFO ][o.e.n.Node ] [WwjX-hI] started
elastic_1 | [2019-09-24T18:00:38,721][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [WwjX-hI] Failed to clear cache for realms [[]]
elastic_1 | [2019-09-24T18:00:38,762][INFO ][o.e.l.LicenseService ] [WwjX-hI] license [9f6ac6c0-620a-4b71-b3e7-da5bb37b8337] mode [basic] - valid
elastic_1 | [2019-09-24T18:00:38,772][INFO ][o.e.g.GatewayService ] [WwjX-hI] recovered [0] indices into cluster_state
推荐答案
docker-compose将服务弹性"公开.此服务在您的Docker网络中是可解析的,因此您的Rails应用应按以下方式连接:
docker-compose exposes the service "elastic". This service is resolvable within your docker network so your rails app should connect like this:
ELASTIC_HOST: "elastic"
桥接模式的容器中的
localhost在该容器本地.
localhost in a container in bridge-mode is local to the container.
这篇关于无法打开到localhost:9200的TCP连接(无法分配请求的地址-&"localhost&"端口9200的connect(2))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!