Docker容器SpringBoot极简教程 · Spring Boot ThoughtWork

Spring Boot Demo with Docker

2018-06-08  本文已影响12人  亨利何

1. Spring starter启动一个web项目

2. Spring maven package 生成可执行jar包

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
java -jar your_app.jar

3. Docker deployment 部署运行

FROM centos

MAINTAINER henryhe

COPY jdk1.8.0_172 jdk1.8.0_172

ADD pj-0.0.1-SNAPSHOT.jar app.jar

# env
ENV JAVA_HOME=/jdk1.8.0_172
ENV PATH=$JAVA_HOME/bin:$PATH
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "/app.jar"]
docker run -p 80:8080 --name springboot your_image_right_here
docker start springboot
docker logs -f
上一篇下一篇

猜你喜欢

热点阅读