I. Engineering structure
Second, the POM configuration
<Build> <Plugins> <plugin> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-maven-plugin</Artifactid> </plugin> <!--tag::p lugin[] - <plugin> <groupId>Com.spotify</groupId> <Artifactid>Docker-maven-plugin</Artifactid> <version>0.4.3</version> <Configuration> <ImageName>${docker.image.prefix}/${project.artifactid}</ImageName> <dockerdirectory>Src/main/docker</dockerdirectory> <Skipdockerbuild>False</Skipdockerbuild> <Resources> <Resource> <TargetPath>/</TargetPath> <Directory>${project.build.directory}</Directory> <include>${project.build.finalname}.jar</include> </Resource> </Resources> </Configuration> </plugin> <!--end::p lugin[] - </Plugins> </Build>
YML configuration information
Server: port:8661# context-path:/helloeureka: instance: prefer-ip-address:true Client: Registerwitheureka:false Fetchregistry:false
Third, dockerfile information
Create Dockerfile file, location: Src/main/docker
From Frolvlad/alpine-oraclejdk8:slimvolume/tmpadd Eureka-server-docker-0.0.1-snapshot.jar app.jar#RUN bash-c ' touch /app.jar ' entrypoint ["Java", "-djava.security.egd=file:/dev/./urandom", "-jar", "/app.jar"]expose 8761
Four, modify the remote Linux Server Docker configuration, the author version is Centos7
1. Edit the Docker.service file
Vi/usr/lib/systemd/system/docker.service
Append- h tcp://0.0.0.0:2375-h unix:///var/run/docker.sock in the line after Execstart
Execstart=/usr/bin/dockerd-current -h tcp://0.0.0.0:2375-h unix:///var/run/docker.sock -- Add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc -- Exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $ OPTIONS $DOCKER _storage_options $DOCKER _network_options $ADD _registry $BLOCK _registry $INSECURE _registry
2. Restart Docker Service
Service Docker restart
3. Check if the port is started
Netstat-anp|grep 2375
4, firewall open 2375 port
Firewall-cmd--zone=public--add-port=2375/tcp--permanent
Firewall-cmd--reload
V. Windows ADD docker_host environment variable
Six, MAVEN package build
MVN Clean Package docker:build-dskiptests
Seven, start the container
Docker run--name eureka-server-p 8661:8661-d mydocker/eureka-server-docker
Viii. Access Testing
Spring could windows package build Docker image to Linux