From 67697ce6dca1474646eeaafd0198e8c45e0b6326 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 19 Dec 2018 14:18:21 +0800 Subject: [PATCH] add docker doc. #364 --- README.md | 1 + README_CN.md | 1 + site/src/site/sphinx/docker.md | 64 +++++++++++++++++++++++++++++++ site/src/site/sphinx/en/docker.md | 64 +++++++++++++++++++++++++++++++ site/src/site/sphinx/en/index.md | 1 + site/src/site/sphinx/index.md | 1 + 6 files changed, 132 insertions(+) create mode 100644 site/src/site/sphinx/docker.md create mode 100644 site/src/site/sphinx/en/docker.md diff --git a/README.md b/README.md index 0024770c0..b3f7db522 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ You can enter its interactive interface by executing `as.sh`, or execute `as.sh * [Quick start](https://alibaba.github.io/arthas/en/quick-start.html) * [Advanced usage](https://alibaba.github.io/arthas/en/advanced-use.html) * [Commands](https://alibaba.github.io/arthas/en/commands.html) +* [Docker](https://alibaba.github.io/arthas/en/docker.html) * [User cases](https://github.com/alibaba/arthas/issues?q=label%3Auser-case) * [Questions and answers](https://github.com/alibaba/arthas/issues?utf8=%E2%9C%93&q=label%3Aquestion-answered+) * [How to contribute](https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md) diff --git a/README_CN.md b/README_CN.md index 218a73e94..34c2b3c56 100644 --- a/README_CN.md +++ b/README_CN.md @@ -68,6 +68,7 @@ curl -L https://alibaba.github.io/arthas/install.sh | sh * [快速入门](https://alibaba.github.io/arthas/quick-start.html) * [进阶使用](https://alibaba.github.io/arthas/advanced-use.html) * [命令列表](https://alibaba.github.io/arthas/commands.html) +* [Docker](https://alibaba.github.io/arthas/docker.html) * [用户案例](https://github.com/alibaba/arthas/issues?q=label%3Auser-case) * [常见问题](https://github.com/alibaba/arthas/issues?utf8=%E2%9C%93&q=label%3Aquestion-answered+) * [参与贡献](https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md) diff --git a/site/src/site/sphinx/docker.md b/site/src/site/sphinx/docker.md new file mode 100644 index 000000000..e8dcb2773 --- /dev/null +++ b/site/src/site/sphinx/docker.md @@ -0,0 +1,64 @@ +Docker +=== + +## 通过Docker快速入门 + +1. 删除本地已有的`arthas-demo` docker container(非必要) + + ```sh + $ docker stop arthas-demo || true && docker rm arthas-demo || true + ``` + +1. 启动`arthas-demo` + + ```sh + $ docker run --name arthas-demo -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/arthas-demo.jar" + ``` + +1. 启动`arthas-boot`来进行诊断 + + ```sh + $ 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 + ``` + +## 诊断Docker里的Java进程 + +```sh +docker exec -it ${containerId} /bin/bash -c "wget https://alibaba.github.io/arthas/arthas-boot.jar && java -jar arthas-boot.jar" +``` + +## 诊断k8s里容器里的Java进程 + +```sh +kubectl exec -it ${pod} --container ${containerId} -- /bin/bash -c "wget https://alibaba.github.io/arthas/arthas-boot.jar && java -jar arthas-boot.jar" +``` + +## 把Arthas安装到基础镜像里 + +可以很简单把Arthas安装到你的Docker镜像里。 + +``` +FROM openjdk:8-jdk-alpine + +# copy arthas +COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas +``` + +* [https://cloud.docker.com/repository/docker/hengyunabc/arthas](https://cloud.docker.com/repository/docker/hengyunabc/arthas) \ No newline at end of file diff --git a/site/src/site/sphinx/en/docker.md b/site/src/site/sphinx/en/docker.md new file mode 100644 index 000000000..0314be118 --- /dev/null +++ b/site/src/site/sphinx/en/docker.md @@ -0,0 +1,64 @@ +Docker +=== + +## Quick start with Docker + +1. Delete the existing `arthas-demo` docker container (not necessary) + + ```sh + $ docker stop arthas-demo || true && docker rm arthas-demo || true + ``` + +1. Start `arthas-demo` + + ```sh + $ docker run --name arthas-demo -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/arthas-demo.jar" + ``` + +1. Start `arthas-boot` for diagnosis + + ```sh + $ 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 + +```sh +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 + +```sh +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 +``` + +* [https://cloud.docker.com/repository/docker/hengyunabc/arthas](https://cloud.docker.com/repository/docker/hengyunabc/arthas) \ No newline at end of file diff --git a/site/src/site/sphinx/en/index.md b/site/src/site/sphinx/en/index.md index 07e145805..03025b341 100644 --- a/site/src/site/sphinx/en/index.md +++ b/site/src/site/sphinx/en/index.md @@ -41,6 +41,7 @@ Contents * [Quick start](quick-start.md) * [Advanced usage](advanced-use.md) * [Commands](commands.md) +* [Docker](docker.md) * [User cases](https://github.com/alibaba/arthas/issues?q=label%3Auser-case) * [Questions and answers](https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered) * [Fork me at GitHub](https://github.com/alibaba/arthas) diff --git a/site/src/site/sphinx/index.md b/site/src/site/sphinx/index.md index 3144a5e57..4f8622823 100644 --- a/site/src/site/sphinx/index.md +++ b/site/src/site/sphinx/index.md @@ -30,6 +30,7 @@ Contents * [快速入门](quick-start.md) * [进阶使用](advanced-use.md) * [命令列表](commands.md) +* [Docker](docker.md) * [用户案例](https://github.com/alibaba/arthas/issues?q=label%3Auser-case) * [常见问题](https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered) * [Fork me at GitHub](https://github.com/alibaba/arthas)