Preface
This is an article related to four knowledge points, namely java, docker, springboot and gradle. We hope to use the springboot framework in the Java environment to build a project through gradle, and then deploy and run the project in the docker container!
For more information about gradle, please refer to this article: //www.VeVB.COM/article/125602.htm
I won’t say much below, let’s take a look at the detailed introduction:
Places to pay attention to
Development process
A build.gradle file
dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath('se.transmode.gradle:gradle-docker:1.2') }apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'org.springframework.boot'apply plugin: 'io.spring.dependency-management'apply plugin: 'docker'version = '1.0.0'jar { baseName = 'springdemo'}task buildDocker(type: Docker, dependsOn: build) { push = true applicationName = jar.baseName dockerfile = file('src/main/docker/Dockerfile') doFirst { copy { from jar into stageDir } }}Second compilation project
docker build
Three generation mirror
docker build buildDocker
Four run containers
docker run -p 80:8080 springdemo-1.0.0
Five years of pictures
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support to Wulin.com.