V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wganbleuthall
V2EX  ›  Docker

docker run 成功, docker compose up 失败?

  •  
  •   wganbleuthall · 2023-06-02 21:01:32 +08:00 · 1339 次点击
    这是一个创建于 540 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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?? 这我该咋办啊

    7 条回复    2023-06-02 21:54:03 +08:00
    Yourshell
        1
    Yourshell  
       2023-06-02 21:09:30 +08:00
    有没有可能是内存给少了
    hingle
        2
    hingle  
       2023-06-02 21:12:48 +08:00
    docker run 端口是 9201 ,docker compose 端口是 9200 ,端口被占用了?
    wganbleuthall
        3
    wganbleuthall  
    OP
       2023-06-02 21:14:47 +08:00
    @Yourshell 不应该啊 给了 4g
    wganbleuthall
        4
    wganbleuthall  
    OP
       2023-06-02 21:15:01 +08:00
    @hingle 两个容器
    caomingjun
        5
    caomingjun  
       2023-06-02 21:24:00 +08:00 via Android
    我感觉不像 healthcheck ,healthcheck 一般是从容器内部发起的
    其实日志输出里有 remoteAddress=/172.19.0.2:42386 ,你搞清楚这个 ip 和端口号上跑的啥玩意不就知道了
    w07128597
        6
    w07128597  
       2023-06-02 21:26:06 +08:00 via iPhone
    我遇到过,默认内存太低了,启动成功后立马就挂了,增加 es 的堆内存就好了,在环境变量中设置
    chotow
        7
    chotow  
       2023-06-02 21:54:03 +08:00
    docker inspect elasticsearch 可以查看退出原因,我试了下,是因为 OOM
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2409 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 02:10 · PVG 10:10 · LAX 18:10 · JFK 21:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.