Docker container launches Spring boot project

Source: Internet
Author: User
Tags docker ps docker run

First, install the Docker environment

Yum Install Docker

After the installation is complete, use the following command to start the Docker service and set it to boot:

Systemctl Start Docker.service

Systemctl Enable Docker.service

Next, use the Docker China accelerator

Vi/etc/docker/daemon.json

#添加后

Restart Docker

Systemctl Restart Docker

The installation was successful when you entered the Docker version to return the release information

Ii. Installation of JDK

Yum-y Install java-1.8.0-openjdk*

Next, with the environment variable open vim/etc/profile add a little bit of content

Export JAVA_HOME=/USR/LIB/JVM/JAVA-1.8.0-OPENJDK-1.8.0.171-7.B10.EL7.X86_64/JRE
Export path= $PATH: $JAVA _home/bin
After the modification is complete, make it effective

Source/etc/profile

Input Java-version return version information is installed normally

Third, install Maven

Download: http://mirrors.shu.edu.cn/apache/maven/maven-3/

There are several versions of Maven in this case, with apache-maven-3.5.3-bin.tar.gz.

#解压

Tar vxf apache-maven-3.5.3-bin.tar.gz

#移动

MV Apache-maven-3.5.2/usr/local/maven3

Modify the environment variables to add the following lines in the/etc/profile

Maven_home=/usr/local/maven3
Export Maven_home
Export Path=${path}:${maven_home}/bin
Remember to execute source/etc/profile to make the environment variable effective.

Then, enter Mvn-version to return the version information to install the normal

################# #到这里环境就配置完成了, the following is the real deployment of the part, because the process is tortuous, may be more detailed, pro-Test available ##############

Start with maven packaging, MVN clean packages, generate jar packs (Spring-boot-docker-0.0.1-snapshot.jar)

Write Dockerfile:

Next, create an empty directory, put Dockerfile and Spring-boot-docker-0.0.1-snapshot.jar in it, build the mirror

Docker build-t Huangll/springboot-docker. (Note that there is a small point here!!!) )

That's probably how it's done.

Sending build context to Docker daemon 16.01 MB
Step: From Openjdk:8-jdk-alpine
---> 224765a6bdbe
Step 2/4: volume/tmp
---> Using cache
---> c34991cf3051
Step 3/4: ADD spring-boot-docker-0.0.1-snapshot.jar App.jar
---> 344587401990
Removing intermediate container A88D2B603C17
Step 4/4: Entrypoint/usr/bin/java-djava.security.egd=file:/dev/./urandom-jar/app.jar
---> Running in 1c270b3dad07
---> 65448657984f
Removing intermediate container 1c270b3dad07
Successfully built 65448657984f

Next: Docker images view mirroring

To run the container:
Docker run-d--name springboot-p 8888:8888 spring-boot/spring-boot-docker

Docker PS Viewing container:

This is a successful release!!!

My only test project, Access path is: http://127.0.0.1:8888/

Docker container launches Spring boot project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.