I am following this docker tutorial, and am running into trouble with docker compose.
The problem is when I run docker-compose up
, the web container fails to connect to the es one, and after a few failing retries, it gives up and dies (the web container then exits by itself).
However, from looking at the logs, it seems that this is because the es container is just taking its time getting started - if I then repeat the docker-compose up
after that (once es is already up and running), the web container works fine.
So I'm wondering, is there a way to specify from within a docker-compose.yml file, a time delay between starting up the containers?
The terminal output where the web container initially fails to connect to es is as follows:
C:\work\docker_learning\FoodTrucks> docker-compose up
Docker Compose is now in the Docker CLI, try docker compose up
Starting es ... done Starting foodtrucks_web_1 ... done Attaching to es, foodtrucks_web_1 es | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. es | [2021-04-25T12:39:43,255][INFO ][o.e.n.Node ] [] initializing ... es | [2021-04-25T12:39:43,411][INFO ][o.e.e.NodeEnvironment ] [_ywWy9B] using 1 data paths, mounts [[/usr/share/elasticsearch/data (/dev/sdc)]], net usable_space [230.9gb], net total_space [250.9gb], types [ext4] es | [2021-04-25T12:39:43,412][INFO ][o.e.e.NodeEnvironment ] [_ywWy9B] heap size [990.7mb], compressed ordinary object pointers [true] es | [2021-04-25T12:39:43,458][INFO ][o.e.n.Node ] [_ywWy9B] node name derived from node ID [_ywWy9B8QZSIn81FhEchNA]; set [node.name] to override es | [2021-04-25T12:39:43,470][INFO ][o.e.n.Node ] [_ywWy9B] version[6.3.2], pid1, build[default/tar/053779d/2018-07-20T05:20:23.451332Z], OS[Linux/4.19.128-microsoft-standard/amd64], JVM["Oracle Corporation"/OpenJDK 64-Bit Server VM/10.0.2/10.0.2+13] es | [2021-04-25T12:39:43,471][INFO ][o.e.n.Node ] [_ywWy9B] 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.4LDlDF7A, -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] es | [2021-04-25T12:39:47,178][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [aggs-matrix-stats] es | [2021-04-25T12:39:47,180][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [analysis-common] es | [2021-04-25T12:39:47,180][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [ingest-common] es | [2021-04-25T12:39:47,180][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [lang-expression] es | [2021-04-25T12:39:47,180][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [lang-mustache] es | [2021-04-25T12:39:47,181][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [lang-painless] es | [2021-04-25T12:39:47,182][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [mapper-extras] es | [2021-04-25T12:39:47,184][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [parent-join] es | [2021-04-25T12:39:47,189][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [percolator] es | [2021-04-25T12:39:47,189][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [rank-eval] es | [2021-04-25T12:39:47,189][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [reindex] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [repository-url] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [transport-netty4] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [tribe] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-core] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-deprecation] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-graph] es | [2021-04-25T12:39:47,190][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-logstash] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-ml] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-monitoring] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-rollup] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-security] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-sql] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-upgrade] es | [2021-04-25T12:39:47,191][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded module [x-pack-watcher] es | [2021-04-25T12:39:47,192][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded plugin [ingest-geoip] es | [2021-04-25T12:39:47,192][INFO ][o.e.p.PluginsService ] [_ywWy9B] loaded plugin [ingest-user-agent] es | [2021-04-25T12:39:52,773][INFO ][o.e.x.s.a.s.FileRolesStore] [_ywWy9B] parsed [0] roles from file [/usr/share/elasticsearch/config/roles.yml] es | [2021-04-25T12:39:55,243][INFO ][o.e.d.DiscoveryModule ] [_ywWy9B] using discovery type [single-node] web_1 | /usr/local/lib/python3.6/dist-packages/requests/init.py:91: RequestsDependencyWarning: urllib3 (1.26.4) or chardet (3.0.4) doesn't match a supported version! web_1 | RequestsDependencyWarning) web_1 | Unable to connect to ES. Retrying in 5 secs... web_1 | Unable to connect to ES. Retrying in 5 secs... web_1 | Out of retries. Bailing out... es | [2021-04-25T12:39:57,622][INFO ][o.e.n.Node ] [_ywWy9B] initialized es | [2021-04-25T12:39:57,623][INFO ][o.e.n.Node ] [_ywWy9B] starting ... es | [2021-04-25T12:39:57,925][INFO ][o.e.t.TransportService ] [_ywWy9B] publish_address {172.26.0.2:9300}, bound_addresses {0.0.0.0:9300} es | [2021-04-25T12:39:58,004][WARN ][o.e.b.BootstrapChecks ] [_ywWy9B] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] es | [2021-04-25T12:39:58,116][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [_ywWy9B] publish_address {172.26.0.2:9200}, bound_addresses {0.0.0.0:9200} es | [2021-04-25T12:39:58,117][INFO ][o.e.n.Node ] [_ywWy9B] started es | [2021-04-25T12:39:59,070][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [_ywWy9B] Failed to clear cache for realms [[]] es | [2021-04-25T12:39:59,147][INFO ][o.e.l.LicenseService ] [_ywWy9B] license [8feb64bb-90d9-4dd7-8c89-a65273596aaa] mode [basic] - valid es | [2021-04-25T12:39:59,173][INFO ][o.e.g.GatewayService ] [_ywWy9B] recovered 1 indices into cluster_state es | [2021-04-25T12:39:59,954][INFO ][o.e.c.r.a.AllocationService] [_ywWy9B] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [sfdata] ...]). `