Giter Site home page Giter Site logo

docker_run_jar's Introduction

一、dockerfile 文件如下

FROM openjdk:8-jre

MAINTAINER zyj
# 新建目录
RUN mkdir /opt/jar/
# 把jar包复制进去
# 需要改为你运行的jar包名称
ADD springboot_demo.jar /opt/jar/

#时区 
RUN echo "Asia/Shanghai" > /etc/timezone

RUN mv /etc/localtime /etc/localtime_bak

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

EXPOSE 8080

WORKDIR /opt/

# Launch JAVA
# 需要改为你运行的jar包名称
CMD ["java", "-jar","/opt/jar/springboot_demo.jar"]

二、使用docker命令打包编译

docker build -f dockerfile -t zyj/springboot .

三、运行

docker run -d -p 8080:8080 --name springboot zyj/springboot 
如果 提示
WARNING: IPv4 forwarding is disabled. Networking will not work.

则 在宿主机器上执行以下代码

vi /etc/sysctl.conf
#添加 
net.ipv4.ip_forward=1
#重启network服务
systemctl restart network
#查看是否修改成功
sysctl net.ipv4.ip_forward
#如果返回为“net.ipv4.ip_forward = 1”则表示成功了

四、在网页上就可以打开了

http://localhost:8080/

五、如果要查看日志

docker exec -it springboot /bin/bash 

cd /opt/jar/logs/
ls

六、github地址

https://github.com/Zhao2018Mr/docker_run_jar

七、CSDN 地址

https://blog.csdn.net/qq_31807569/article/details/90475094

docker_run_jar's People

Contributors

zhao2018mr avatar

Stargazers

 avatar

Forkers

zhengbangzhuang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.