2

How can I install jmap on my docker container to get its heap dump once its deployed to AWS ECS as a container.I am using distroless as my base java image.Below is my dockerFile.I have managed to install all other utilities in my container other than jmap

FROM progrium/busybox as prgbusybox
RUN opkg-install curl bash git
FROM busybox:1.35.0-uclibc as busybox
FROM gcr.io/distroless/java:11
COPY --from=busybox /bin/wget /bin/wget
COPY --from=prgbusybox /usr/bin/curl /bin/curl
COPY --from=prgbusybox /bin/cat /bin/cat
COPY --from=prgbusybox /bin/ls /bin/ls
COPY --from=prgbusybox /bin/grep /bin/grep
COPY --from=prgbusybox /bin/ps /bin/ps
COPY --from=prgbusybox /bin/cp /bin/cp
COPY --from=prgbusybox /bin/chmod /bin/chmod
COPY --from=prgbusybox /bin/mkdir /bin/mkdir
COPY --from=prgbusybox /bin/sh /bin/sh
COPY target/my-app*.jar /app/app.jar
WORKDIR /app
RUN wget https://github.com/apangin/jattach/releases/download/v1.5/jattach && chmod +x jattach
ENTRYPOINT ["java","-Xlog:gc=debug:file=./gc.log:time,uptime,level,tags:filecount=10,filesize=10m", "-XX:InitialHeapSize=700M","-XX:MaxHeapSize=1024M", "-jar", "app.jar"]
HEALTHCHECK NONE

1 Answer 1

0

Install openjdk in container

apk update
apk add openjdk8

Generate heapdump

kubectl exec -it ${pod_name} -n ${namespace} -- /bin/sh -c "jmap -dump:format=b,file=heapdump.hprof $PID"

Copy in your local and Remove it from pod

kubectl cp -n ${namespace} ${pod_name}:/heapdump.hprof ./heapdump.hprof --retries 10
kubectl exec -it ${pod_name} -n ${namespace} -- /bin/sh -c "rm -rf /heapdump.hprof"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.