- Base on the latest version of official alpine Docker Image : link
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
javac 1.8.0_191The most straightforward way to use this image is to use a Java container as both the build and runtime environment. In your Dockerfile, writing something along the lines of the following will compile and run your project:
FROM ringcentral/jdk:latest
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac Main.java
CMD ["java", "Main"]
You can then run and build the Docker image:
$ docker build -t my-java-app . $ docker run -it --rm --name my-running-app my-java-app
RUN apk update && apk add --no-cache tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone && apk del tzdatafor more detail information please refer this url: https://github.com/ringcentral-docker/jdk
如果java程序使用pyroscope有类似如下报错 libstdc++.so.6: cannot open shared object file: No such file or directory
则在Dockerfile中添加 RUN apk add --no-cache postgresql-client bash openssl libgcc libstdc++ ncurses-libs