Spring could windows package build Docker image to Linux

Source: Internet
Author: User
Tags docker run

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

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.