When a Neo4j container exits, either expected or unexpected, the container orchestration layer will report back the exit code of the container's entrypoint process. In the case of unexpected terminations, this exit code can be used to understand why the process exited.
Container exit codes typically follow a standard convention where a code of 0 indicates a successful exit, while non-zero codes indicate various types of errors or issues that caused the container to terminate.
In the below examples, exit code 3 corresponds to an out of memory exception in the JVM. Specifically, in these examples, -XX:+ExitOnOutOfMemoryError
is enabled and the container will exit immediately in the event of an out of memory exception. There are other exit codes that could be displayed.
Checking the exit code
The method for checking a container's exit code varies depending on the container orchestration technology in use. Below, we provide examples for both Docker and Kubernetes.
Docker
The exit code can be seen in the STATUS
column using docker ps -a
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0659374ef8b5 neo4j:4.4-enterprise "tini -g -- /startup…" 3 minutes ago Exited (3) About a minute ago neo4j
The following example narrows down the returned information to just an exit code
$ docker inspect neo4j --format='{{.State.ExitCode}}'
3
Kubernetes
The exit code can be seen in the pod description using kubectl describe pod POD_NAME
$ kubectl describe pod neo4j-0
...
Containers:
neo4j:
Container ID: docker://b39830acf75ac8cb27db2453a739d24359c30a1408bd469eb54a5b84c7a5332d
Image: neo4j:4.4.21-enterprise
Image ID: docker-pullable://neo4j@sha256:0d63991f54111dd5559781b27e8f531f8f7a7d5ab4da95fca1b5d714a789d0b8
Ports: 7474/TCP, 7687/TCP, 7473/TCP, 6362/TCP
Host Ports: 0/TCP, 0/TCP, 0/TCP, 0/TCP
State: Running
Started: Thu, 14 Sep 2023 12:52:26 +0100
Last State: Terminated
Reason: Error
Exit Code: 3
...
The following example narrows down the returned information to just an exit code
$ kubectl get pod neo4j-0 -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.exitCode}}{{end}}"
3
Comments
0 comments
Article is closed for comments.