docker run 成功, docker compose up 失败?

2023-06-02 21:01:32 +08:00
 wganbleuthall

docker run -it -p 9201:9200 --network elastic --name es2 elasticsearch:8.7.1没有任何问题,几秒之后就会出现 ✅ Elasticsearch security features have been automatically configured! ✅ Authentication is enabled and cluster connections are encrypted.


但是 docker-compose.yml

version: "3.9"
services:
  logstash:
    image: logstash:8.7.1
    container_name: logstash
    networks:
      - elastic
    ports:
      - "5044:5044"
    volumes:
      - ./elk/pipeline:/usr/share/logstash/pipeline:rw,Z
    restart: unless-stopped
    depends_on:
      - kibana
  kibana:
    image: kibana:8.7.1
    container_name: kibana
    networks:
      - elastic
    ports:
      - "5601:5601"
    restart: always
  elasticsearch:
    image: elasticsearch:8.7.1
    container_name: elasticsearch
    deploy:
      resources:
        reservations:
          memory: 4GB
    networks:
      - elastic
    ports:
      - "9200:9200"
    restart: no


networks:
  elastic:
    name: elastic
    external: true

这样子启动的 elasticsearch 就会无限打印

{"@timestamp":"2023-06-02T12:25:51.290Z", "log.level": "WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.19.0.3:9200, remoteAddress=/172.19.0.2:42386}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[bb66f54e0118][transport_worker][T#2]","log.logger":"org.elasticsearch.http.netty4.Netty4HttpServerTransport","elasticsearch.cluster.uuid":"7sT8niyaQeqs2oZAn8TLLg","elasticsearch.node.id":"jg-nmYbcQZmdM5Jfy_fMfw","elasticsearch.node.name":"bb66f54e0118","elasticsearch.cluster.name":"docker-cluster"}

然后几分钟后就ERROR: Elasticsearch exited unexpectedly,为什么,我无法理解了,还没有任何的 error 日志 它要是显示启动成功的那两个绿勾勾再无限打印 warning 也就算了,可是压根启动不成功


一开始我以为是 docker compose 启动过程中 kibana 不停给 elasticsearch 发 http 导致启动失败,但是 depends-on 完全不起作用,甚至我将 docker compose yml 删了只剩 elasticsearch 一个服务还是不行 但是 docker run ...就没有那串日志,所以难道 docker compose 在启动的时候,docker engine 不停给 elasticsearch 发什么 http 吗,healthcheck?? 这我该咋办啊

1335 次点击
所在节点    Docker
7 条回复
Yourshell
2023-06-02 21:09:30 +08:00
有没有可能是内存给少了
hingle
2023-06-02 21:12:48 +08:00
docker run 端口是 9201 ,docker compose 端口是 9200 ,端口被占用了?
wganbleuthall
2023-06-02 21:14:47 +08:00
@Yourshell 不应该啊 给了 4g
wganbleuthall
2023-06-02 21:15:01 +08:00
@hingle 两个容器
caomingjun
2023-06-02 21:24:00 +08:00
我感觉不像 healthcheck ,healthcheck 一般是从容器内部发起的
其实日志输出里有 remoteAddress=/172.19.0.2:42386 ,你搞清楚这个 ip 和端口号上跑的啥玩意不就知道了
w07128597
2023-06-02 21:26:06 +08:00
我遇到过,默认内存太低了,启动成功后立马就挂了,增加 es 的堆内存就好了,在环境变量中设置
chotow
2023-06-02 21:54:03 +08:00
docker inspect elasticsearch 可以查看退出原因,我试了下,是因为 OOM

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/945345

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX