Docker¶
Quick start with Docker¶
Delete the existing arthas-demo docker container (not necessary)
$ docker stop arthas-demo || true && docker rm arthas-demo || true
Start arthas-demo
$ docker run --name arthas-demo -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/arthas-demo.jar"
Start arthas-boot for diagnosis
$ docker exec -it arthas-demo /bin/sh -c "java -jar /opt/arthas/arthas-boot.jar" * [1]: 9 jar [INFO] arthas home: /opt/arthas [INFO] Try to attach process 9 [INFO] Attach process 9 success. [INFO] arthas-client connect 127.0.0.1 3658 ,---. ,------. ,--------.,--. ,--. ,---. ,---. / O \ | .--. ''--. .--'| '--' | / O \ ' .-' | .-. || '--'.' | | | .--. || .-. |`. `-. | | | || |\ \ | | | | | || | | |.-' | `--' `--'`--' '--' `--' `--' `--'`--' `--'`-----' wiki: https://alibaba.github.io/arthas version: 3.0.5 pid: 9 time: 2018-12-18 11:30:36
Diagnose the Java process in Docker¶
docker exec -it ${containerId} /bin/bash -c "wget https://alibaba.github.io/arthas/arthas-boot.jar && java -jar arthas-boot.jar"
Diagnose the Java process in the container in k8s¶
kubectl exec -it ${pod} --container ${containerId} -- /bin/bash -c "wget https://alibaba.github.io/arthas/arthas-boot.jar && java -jar arthas-boot.jar"
Install Arthas into the base Docker image¶
It’s easy to install Arthas into your Docker image.
FROM openjdk:8-jdk-alpine
# copy arthas
COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas