cat Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
FROM centos MAINTAINER REX # ADD 会将tar包解压 ADD ./jdk-17_linux-x64_bin.tar.gz /opt RUN mkdir -p /opt/jdk-17.0.4 ENV JAVA_HOME /opt/jdk-17.0.4 ENV PATH $PATH:$JAVA_HOME/bin ENV LANG="en_US.UTF-8" COPY ./websocket-server.jar /opt/ EXPOSE 8080 VOLUME ["/opt/logs"] WORKDIR /opt/ ENTRYPOINT java -jar /opt/websocket-server.jar |
// '.'表示build context为当前目录
docker build -t jdk-test .
// -v 指定volume映射 主机目录:容器目录 -p 端口映射
docker run -d -v /var/logs:/opt/logs -p 8080:8080 jdk-test:v2.0
Posted in: Linux
Comments are closed.