update docker.md

This commit is contained in:
hengyunabc
2020-09-22 11:21:08 +08:00
parent 9e433a26c0
commit ffc411b6ea
2 changed files with 108 additions and 0 deletions
+53
View File
@@ -1,6 +1,59 @@
Docker
===
## 在Docker里使用JDK
很多时候,应用在docker里出现arthas无法工作的问题,是因为应用没有安装 JDK ,而是安装了 JRE 。如果只安装了 JRE,则会缺少很多JAVA的命令行工具和类库,Arthas也没办法正常工作。下面介绍两种常见的在Docker里使用JDK的方式。
### 使用公开的JDK镜
* https://hub.docker.com/_/openjdk/
比如:
```
FROM openjdk:8-jdk
```
或者:
```
FROM openjdk:8-jdk-alpine
```
### 通过包管理软件来安装
比如:
```bash
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
```
或者:
```bash
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN export JAVA_HOME
```
## 通过Docker快速入门
1. 删除本地已有的`arthas-demo` docker container(非必要)
+55
View File
@@ -1,6 +1,61 @@
Docker
===
## Use JDK in Docker
Many times, the problem that arthas can't work with the application in docker is because the docker does not install JDK, but installs JRE. If only JRE is installed, many JAVA command line tools and class libraries will be missing, and Arthas will not work properly. Here are two common ways to use JDK in Docker.
### Use public JDK image
* https://hub.docker.com/_/openjdk/
such as:
```
FROM openjdk:8-jdk
```
or:
```
FROM openjdk:8-jdk-alpine
```
### Install via package management software
such as:
```bash
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME - useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
```
or:
```bash
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN export JAVA_HOME
```
## Quick start with Docker
1. Delete the existing `arthas-demo` docker container (not necessary)