Docker deployment springboot, start with a simple Eureka

Foreword

docker build mirroring, deployment springboot project is not new, because docker's continuous integration, version control, portability, and security isolation, etc., such that it is widely used.
Today, I will share with you a simple deployment process in Eureka.

Project Package

The simple premise of this article Eureka project uses Maven labeled jar package ( eureka-server-1.0.0.jar); Because Docker mounted Ali cloud, it will lay the jar on a cloud server (new folder /usr/local/dev/docker/testProject/),
specific packaging process there are many online sharing, not this go into detail.

Dockerfile

What is Dockerfile

Dockerfile Docker image is used to construct the build file, the script is a series of commands and configuration parameters.

Construction of three-step mirror

  1. Write Dockerfile file
  • Dockerfile written documents and eureka-server-1.0.0.jar on the same level directory

  • Content Dockerfile profile
FROM java:8
VOLUME /tmp
ADD eureka-server-1.0.0.jar /eureka-server.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/eureka-server.jar"]
  • java: 8 is to use jdk version
  • VOLUME configuration data volume
  • ADD copy files to and extract the mirror, eureka-server-1.0.0.jarwe lay the jar package, eureka-server.jarmirroring a custom container name
  • Command to start the execution of the container when ENTRYPOINT
  1. Construction of execution Docker image
注意后面有个 .
docker build -t eureka-server .
  • -t specify a new name eureka-server mirroring
  • Indicates Dockfile in the current path


After creating the image, already present in this case Docker eureka-server mirroring.

  1. ** running just built into the mirror *
docker run -d -p 1001:1001 --name eureka-server eureka-server
  • -d background
  • -P jar coated with port 1001, the host 1001 port mapping, the container port 1001
  • --name: the name of the specified container

By docker psCheck that the container is already running

  1. Browser access

HTTP: ip + 1001 Eureka successful start

Guess you like

Origin www.cnblogs.com/joe-tang/p/12336816.html