• springboot docker 部署


    1.新建一个最简单的springboot项目

    https://code.aliyun.com/859143303/hello-world.git

    2.src/main/docker下新建Dockerfile:

    FROM openjdk:8
    MAINTAINER xc
    ADD docker-hello-world-0.0.1-SNAPSHOT.jar /app/my-docker-hello-world.jar
    CMD ["java", "-Xmx200m", "-jar", "/app/my-docker-hello-world.jar"]
    EXPOSE 6083

    3.pom.xml中增加docker-maven-plugin:

    <!--在build的 plugins中添加 Docker构建插件 -->
    <!-- Docker maven plugin -->
    <plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>1.0.0</version>
    <configuration>
    <imageName>192.168.199.100:5000/docker-hello-world</imageName>
    <!--<imageName>${docker.image.prefix}/${project.artifactId}</imageName>-->
    <dockerDirectory>src/main/docker</dockerDirectory>
    <dockerHost>http://192.168.199.100:2375</dockerHost>
    <resources>
    <resource>
    <targetPath>/</targetPath>
    <directory>${project.build.directory}</directory>
    <include>${project.build.finalName}.jar</include>
    </resource>
    </resources>
    </configuration>
    </plugin>
    <!-- Docker maven plugin -->

    4.mvn clean package

    5.构建镜像

    6.连接到服务器上,启动

    docker run --name my-docker-hello -p 6083:6083 -d 192.168.199.100:5000/docker-hello-world

    7.访问:

    http://192.168.199.100:6083/

  • 相关阅读:
    ansible二
    ansible一
    MySQL索引
    MySQL binlog server原理与搭建
    MySQL online DDL 白话
    MySQL online ddl原理
    Microsoft Visual C++ 14.0 is required解决方法
    man的汉化及使用
    对象,类,命名空间,继承......
    PHP初识
  • 原文地址:https://www.cnblogs.com/ooo0/p/11829547.html
Copyright © 2020-2023  润新知