在docker容器中使用akka应用程序的问题

前端之家收集整理的这篇文章主要介绍了在docker容器中使用akka应用程序的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我们有一个在非集群模式下运行的akka​​应用程序(不是akka集群).
我们正在尝试将此应用程序停靠,并遇到问题.我们正在使用docker主机网络,并且由于各种其他原因,我们尚未准备好使用其他类型的网络.

应用程序绑定到端口9080上的0.0.0.0接口,并自行执行简单的http运行状况检查.
此运行状况检查失败,因为我们看到连接重置错误.我们只在docker容器内看到这个.

在启动期间,应用程序绑定到0:0:0:0:0:0:0:0:9080.
2018-04-13T08:29:54.921-0700 [INFO] – 绑定到/ 0:0:0:0:0:0:0:0:9080

akka日志:

2018-04-13T08:34:25.311-0700 [DEBUG] akka.io.TcpListener            [15:34:25.311UTC] - New connection accepted
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.SelectionHandler       [15:34:25.312UTC] - now supervising Actor[akka://appname/system/IO-TCP/selectors/$d/12#394551476]
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.312UTC] - started (akka.io.TcpIncomingConnection@1dafecc7)
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.312UTC] - now watched by Actor[akka://appname/system/IO-TCP/selectors/$d#992175932]
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.312UTC] - now watched by Actor[akka://appname/user/IO-HTTP/listener-0/88#-1187840999]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.SelectionHandler       [15:34:25.313UTC] - now supervising Actor[akka://appname/system/IO-TCP/selectors/$h/11#789402148]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - started (akka.io.TcpOutgoingConnection@62c77639)
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - now watched by Actor[akka://appname/system/IO-TCP/selectors/$h#227381172]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - Attempting connection to [/0.0.0.0:9080]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpListener            [15:34:25.313UTC] - New connection accepted
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - Connection established to [/0.0.0.0:9080]
2018-04-13T08:34:25.314-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.314UTC] - now watched by Actor[akka://appname/user/IO-HTTP/group-0/52#1518564728]
2018-04-13T08:34:25.314-0700 [DEBUG] akka.io.SelectionHandler       [15:34:25.314UTC] - now supervising Actor[akka://appname/system/IO-TCP/selectors/$h/12#1641348988]
2018-04-13T08:34:25.314-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.314UTC] - started (akka.io.TcpIncomingConnection@65bac45)
2018-04-13T08:34:25.314-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.314UTC] - now watched by Actor[akka://appname/system/IO-TCP/selectors/$h#227381172]
2018-04-13T08:34:26.327-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:26.327UTC] - now watched by Actor[akka://appname/user/IO-HTTP/listener-0/89#-1079090421]
2018-04-13T08:34:26.327-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:26.327UTC] - stopped
2018-04-13T08:34:26.327-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:26.327UTC] - Closing connection due to IO error java.io.IOException: Connection reset by peer
2018-04-13T08:34:26.327-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:26.327UTC] - stopped
2018-04-13T08:34:26.328-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:26.328UTC] - stopped

喷雾日志:

2018-04-13T08:35:39.168-0700 - Dispatching GET request to http://10.4.4.178:9080/admin/health to handler Actor[akka://appname/system/IO-TCP/selectors/$b/20#-595408603]
2018-04-13T08:35:45.296-0700 - Dispatching GET request to http://10.4.4.178:9080/admin/health to handler Actor[akka://appname/system/IO-TCP/selectors/$d/19#721242322]
2018-04-13T08:35:51.372-0700 - Dispatching GET request to http://10.4.4.178:9080/admin/health to handler Actor[akka://appname/system/IO-TCP/selectors/$c/16#1510321611]
2018-04-13T08:35:57.436-0700 - Dispatching GET request to http://10.4.4.178:9080/admin/health to handler Actor[akka://appname/system/IO-TCP/selectors/$g/22#1994752981]
2018-04-13T08:36:03.622-0700 - Dispatching GET request to http://10.4.4.178:9080/admin/health to handler Actor[akka://appname/system/IO-TCP/selectors/$f/20#-1450294853]

健康检查日志

2018-04-13T08:32:53.356-0700 [INFO ] - [BEGIN] Health check
2018-04-13T08:32:53.356-0700 [DEBUG] - Memory    : SUCCESS
2018-04-13T08:32:54.378-0700 [DEBUG] - HTTP      : FAILURE,spray.can.Http$ConnectionException: ErrorClosed(Connection reset by peer)
2018-04-13T08:32:54.378-0700 [ERROR] - spray.can.Http$ConnectionException: ErrorClosed(Connection reset by peer)
    at spray.can.client.HttpHostConnectionSlot.reportDisconnection(HttpHostConnectionSlot.scala:228)
    at spray.can.client.HttpHostConnectionSlot$$anonfun$connected$1.applyOrElse(HttpHostConnectionSlot.scala:161)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
    at spray.can.client.HttpHostConnectionSlot.aroundReceive(HttpHostConnectionSlot.scala:33)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
    at akka.actor.ActorCell.invoke_aroundBody0(ActorCell.scala:487)
    at akka.actor.ActorCell$AjcClosure1.run(ActorCell.scala:1)
    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
    at akka.instrumentation.ActorCellInstrumentation.aroundBehavIoUrInvoke(ActorCellInstrumentation.scala:66)
    at akka.actor.ActorCell.invoke(ActorCell.scala:483)
    at akka.dispatch.MailBox.processMailBox(MailBox.scala:238)
    at akka.dispatch.MailBox.run(MailBox.scala:220)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

2018-04-13T08:32:54.378-0700 [INFO ] - [END  ] Status: Failed (1022 ms)

Dockerfile:

FROM java-base:0.2.3
EXPOSE 9080 9081
ENV MAIN_CLASS="akka.kernel.Main" \
    ADMIN_PORT="9080" \
    HEALTHCHECK_URI="/admin/health" \
    TEMPLATES="/app/templates/override.settings.tmpl:/app/conf/override.settings /app/templates/environment.conf.tmpl:/app/conf/environment.conf" \
    JMX_PORT="9081" \
    APP_NAME="appname" \
    APP_VERSION="1.34.0" \
    CLASSPATH="/app/conf" \
    ENV_FILES="/app/conf/override.settings" \
    INSTRUMENTATION_PATH="/app/ext" \
    JVM_MISC_OPTS="-Dpid=1 \
                  -Dlog4j.configuration=file:///app/conf/log4j.xml \
                  -javaagent:\${INSTRUMENTATION_PATH}/aspectjweaver-1.7.4.jar \
                  -Dlog4j.configuration=file:///app/conf/log4j.xml \
                  -Dlogs.dir=/app/logs \
                  -Dakka.home=/app \
                  -Dakka.kernel.quiet=false \
                  -Dconfig.file=/app/conf/environment.conf" \
    MAIN_CLASS_ARGS=appname.Boot
ADD ext /app/ext
ADD deps /app/libs
ADD templates/ /app/templates/    

Docker-compose文件

version: '3.3'
services:
  appname:
    container_name: appname
    image: appname:1.34.0
    network_mode: host
    restart: unless-stopped
    ulimits:
      nofile:
        soft: 65535
        hard: 65535
    environment:
      UID:
      SDLC_ENVIRONMENT:
      REGION:
      PARTITION:
      TAGS:
      INTERNAL_IP:
      CONSUL_ADDRESS:
      DOCKER_GID:
      MAIN_CLASS_ARGS: appname.Boot
    volumes:
      - "./logs:/app/logs"

Akka配置:

2018-04-17T11:39:17.753-0700 [DEBUG] akka.event.EventStream         [18:39:17.713UTC] - Default Loggers started
2018-04-17T11:39:17.755-0700 [INFO ] akka.actor.ActorSystemImpl     [18:39:17.738UTC] - {
    "akka" : {
        "actor" : {
            "creation-timeout" : "20s","debug" : {
                "autoreceive" : "off","event-stream" : "off","fsm" : "off","lifecycle" : "off","receive" : "off","router-misconfiguration" : "off","unhandled" : "off"
            },"default-dispatcher" : {
                "attempt-teamwork" : "on","default-executor" : {
                    "fallback" : "fork-join-executor"
                },"executor" : "default-executor","fork-join-executor" : {
                    "parallelism-factor" : 16,"parallelism-min" : 8,"task-peeking-mode" : "FIFO"
                },"mailBox-requirement" : "","shutdown-timeout" : "1s","thread-pool-executor" : {
                    "allow-core-timeout" : "on","core-pool-size-factor" : 3,"core-pool-size-max" : 64,"core-pool-size-min" : 8,"keep-alive-time" : "60s","max-pool-size-factor" : 3,"max-pool-size-max" : 64,"max-pool-size-min" : 8,"task-queue-size" : -1,"task-queue-type" : "linked"
                },"throughput" : 1,"throughput-deadline-time" : "0ms","type" : "Dispatcher"
            },"default-mailBox" : {
                "mailBox-capacity" : 1000,"mailBox-push-timeout-time" : "10s","mailBox-type" : "akka.dispatch.UnboundedMailBox","stash-capacity" : -1
            },"deployment" : {
                "default" : {
                    "dispatcher" : "","mailBox" : "","nr-of-instances" : 1,"resizer" : {
                        "backoff-rate" : 0.1,"backoff-threshold" : 0.3,"enabled" : "off","lower-bound" : 1,"messages-per-resize" : 10,"pressure-threshold" : 1,"rampup-rate" : 0.2,"upper-bound" : 10
                    },"routees" : {
                        "paths" : []
                    },"router" : "from-code","tail-chopping-router" : {
                        "interval" : "10 milliseconds"
                    },"virtual-nodes-factor" : 10,"within" : "5 seconds"
                }
            },"dsl" : {
                "default-timeout" : "5s","inBox-size" : 1000
            },"guardian-supervisor-strategy" : "akka.actor.DefaultSupervisorStrategy","mailBox" : {
                "bounded-deque-based" : {
                    "mailBox-type" : "akka.dispatch.BoundedDequeBasedMailBox"
                },"bounded-queue-based" : {
                    "mailBox-type" : "akka.dispatch.BoundedMailBox"
                },"requirements" : {
                    "akka.dispatch.BoundedDequeBasedMessageQueueSemantics" : "akka.actor.mailBox.bounded-deque-based","akka.dispatch.BoundedMessageQueueSemantics" : "akka.actor.mailBox.bounded-queue-based","akka.dispatch.DequeBasedMessageQueueSemantics" : "akka.actor.mailBox.unbounded-deque-based","akka.dispatch.MultipleConsumerSemantics" : "akka.actor.mailBox.unbounded-queue-based","akka.dispatch.UnboundedDequeBasedMessageQueueSemantics" : "akka.actor.mailBox.unbounded-deque-based","akka.dispatch.UnboundedMessageQueueSemantics" : "akka.actor.mailBox.unbounded-queue-based"
                },"unbounded-deque-based" : {
                    "mailBox-type" : "akka.dispatch.UnboundedDequeBasedMailBox"
                },"unbounded-queue-based" : {
                    "mailBox-type" : "akka.dispatch.UnboundedMailBox"
                }
            },"provider" : "akka.actor.LocalActorRefProvider","reaper-interval" : "5s","router" : {
                "type-mapping" : {
                    "balancing-pool" : "akka.routing.BalancingPool","broadcast-group" : "akka.routing.BroadcastGroup","broadcast-pool" : "akka.routing.BroadcastPool","consistent-hashing-group" : "akka.routing.ConsistentHashingGroup","consistent-hashing-pool" : "akka.routing.ConsistentHashingPool","from-code" : "akka.routing.NoRouter","random-group" : "akka.routing.RandomGroup","random-pool" : "akka.routing.RandomPool","round-robin-group" : "akka.routing.RoundRobinGroup","round-robin-pool" : "akka.routing.RoundRobinPool","scatter-gather-group" : "akka.routing.ScatterGatherFirstCompletedGroup","scatter-gather-pool" : "akka.routing.ScatterGatherFirstCompletedPool","smallest-mailBox-pool" : "akka.routing.SmallestMailBoxPool","tail-chopping-group" : "akka.routing.TailChoppingGroup","tail-chopping-pool" : "akka.routing.TailChoppingPool"
                }
            },"serialization-bindings" : {
                "[B" : "bytes","java.io.Serializable" : "java"
            },"serialize-creators" : "off","serialize-messages" : "off","serializers" : {
                "bytes" : "akka.serialization.ByteArraySerializer","java" : "akka.serialization.JavaSerializer"
            },"typed" : {
                "timeout" : "5s"
            },"unstarted-push-timeout" : "10s"
        },"daemonic" : "off","extensions" : [],"home" : "/app","io" : {
            "pinned-dispatcher" : {
                "executor" : "thread-pool-executor","thread-pool-executor" : {
                    "allow-core-pool-timeout" : "off","allow-core-timeout" : "off"
                },"type" : "PinnedDispatcher"
            },"tcp" : {
                "batch-accept-limit" : 10,"direct-buffer-pool-limit" : 1000,"direct-buffer-size" : "128 KiB","file-io-dispatcher" : "akka.actor.default-dispatcher","file-io-transferTo-limit" : "512 KiB","finish-connect-retries" : 5,"management-dispatcher" : "akka.actor.default-dispatcher","max-channels" : 256000,"max-received-message-size" : "unlimited","nr-of-selectors" : 10,"register-timeout" : "5s","selector-association-retries" : 10,"selector-dispatcher" : "akka.io.pinned-dispatcher","trace-logging" : "off","windows-connection-abort-workaround-enabled" : "off","worker-dispatcher" : "akka.actor.default-dispatcher"
            },"udp" : {
                "direct-buffer-pool-limit" : 1000,"max-channels" : 4096,"nr-of-selectors" : 1,"receive-throughput" : 3,"received-message-size-limit" : "unlimited","select-timeout" : "infinite","udp-connected" : {
                "direct-buffer-pool-limit" : 1000,"worker-dispatcher" : "akka.actor.default-dispatcher"
            }
        },"jvm-exit-on-fatal-error" : "on","kernel" : {
            "quiet" : "true"
        },"log-config-on-start" : "on","log-dead-letters" : 10,"log-dead-letters-during-shutdown" : "on","logger-startup-timeout" : "5s","loggers" : [
            "akka.event.slf4j.Slf4jLogger"
        ],"loglevel" : "DEBUG","scheduler" : {
            "implementation" : "akka.actor.LightArrayRevolverScheduler","shutdown-timeout" : "5s","tick-duration" : "10ms","ticks-per-wheel" : 512
        },"stdout-loglevel" : "WARNING","version" : "2.3.16"
    },"awt" : {
        "toolkit" : "sun.awt.X11.XToolkit"
    },"java" : {
        "version" : "1.8.0_121","vm" : {
            "info" : "mixed mode","name" : "Java HotSpot(TM) 64-Bit Server VM","specification" : {
                "name" : "Java Virtual Machine Specification","vendor" : "Oracle Corporation","version" : "1.8"
            },"version" : "25.121-b13"
        }
    }
    "pid" : "1","spray" : {
        "can" : {
            "client" : {
                "chunkless-streaming" : "off","connecting-timeout" : "10s","idle-timeout" : "610s","max-encryption-chunk-size" : "1m","parsing" : {
                    "header-cache" : {
                        "Content-MD5" : 0,"Date" : 0,"If-Match" : 0,"If-Modified-Since" : 0,"If-None-Match" : 0,"If-Range" : 0,"If-Unmodified-Since" : 0,"User-Agent" : 32,"default" : 12
                    },"illegal-header-warnings" : "off","incoming-auto-chunking-threshold-size" : "infinite","max-chunk-ext-length" : 256,"max-chunk-size" : "1m","max-content-length" : "8m","max-header-count" : 64,"max-header-name-length" : 64,"max-header-value-length" : "8k","max-response-reason-length" : 64,"max-uri-length" : "2k","ssl-session-info-header" : "off","uri-parsing-mode" : "strict"
                },"proxy" : {
                    "http" : "default","https" : "default"
                },"reaping-cycle" : "250 ms","request-header-size-hint" : 512,"request-timeout" : "605s","response-chunk-aggregation-limit" : "5m","ssl-tracing" : "off","user-agent-header" : "spray-can/1.3.2"
            },"connection-dispatcher" : "akka.actor.default-dispatcher","host-connector" : {
                "client" : {
                    "chunkless-streaming" : "off","idle-timeout" : "60 s","parsing" : {
                        "header-cache" : {
                            "Content-MD5" : 0,"default" : 12
                        },"illegal-header-warnings" : "on","uri-parsing-mode" : "strict"
                    },"proxy" : {
                        "http" : "default","https" : "default"
                    },"request-timeout" : "20 s","response-chunk-aggregation-limit" : "1m","user-agent-header" : "spray-can/1.3.2"
                },"idle-timeout" : "30 s","max-connections" : 100,"max-redirects" : 0,"max-retries" : 0,"pipelining" : "off"
            },"host-connector-dispatcher" : "akka.actor.default-dispatcher","listener-dispatcher" : "akka.actor.default-dispatcher","manager-dispatcher" : "akka.actor.default-dispatcher","parsing" : {
                "header-cache" : {
                    "Content-MD5" : 0,"default" : 12
                },"uri-parsing-mode" : "strict"
            },"server" : {
                "automatic-back-pressure-handling" : "on","back-pressure" : {
                    "noack-rate" : 10,"reading-low-watermark" : "infinite"
                },"bind-timeout" : "1s","chunkhandler-registration-timeout" : "500 ms","chunkless-streaming" : "off","default-host-header" : "","max-header-value-length" : "16k","uri-parsing-mode" : "relaxed-with-raw-query"
                },"parsing-error-abort-timeout" : "2s","pipelining-limit" : 1,"raw-request-uri-header" : "off","registration-timeout" : "1s","remote-address-header" : "on","request-chunk-aggregation-limit" : "1m","response-header-size-hint" : 512,"server-header" : "BlueJeans Proxy","ssl-encryption" : "off","stats-support" : "on","timeout-handler" : "","timeout-timeout" : "2 s","transparent-head-requests" : "on","unbind-timeout" : "1s","verbose-error-messages" : "off"
            },"settings-group-dispatcher" : "akka.actor.default-dispatcher"
        }
        "version" : "1.3.2"
    }
}

2018-04-17T11:39:20.980-0700 [DEBUG] akka.io.TcpListener            [18:39:20.979UTC] - Successfully bound to /10.4.4.178:9080

版本:
akka – 2.3.0
喷雾 – 1.3.2
在docker容器内的alpine linux上运行.

任何指针都会有所帮助.提前致谢.

最佳答案
在docker-compose文件中,在appname下定义端口映射.

ports:
    9080:9080
原文链接:https://www.f2er.com/docker/436930.html

猜你在找的Docker相关文章