1.springboot项目打成jar包

mvn install

2.编写Dockerfile

# 基础镜像使用java
FROM java:8
# 作者
#MAINTAINER sk
# VOLUME 指定了临时文件目录为/tmp。
# 其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp
VOLUME /tmp
# 将jar包添加到容器中并更名为app.jar
ADD demo1-0.0.1-SNAPSHOT.jar app.jar
# 运行jar包
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

3.把jar包和Dockerfile放在同一个文件夹里(a)

4.进入文件夹然后运行

root@songke-ubuntu:~/Study/IdeaProjects/demo1/a# docker build -t demo1 .

5.等待

root@songke-ubuntu:~/Study/IdeaProjects/demo1/a# docker build -t demo1 .
Sending build context to Docker daemon 16.82MB
Step 1/5 : FROM java:8
8: Pulling from library/java
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
60170fec2151: Pull complete
e98f73de8f0d: Pull complete
11f7af24ed9c: Pull complete
49e2d6393f32: Pull complete
bb9cdec9c7f3: Pull complete
Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
Status: Downloaded newer image for java:8
---> d23bdf5b1b1b
Step 2/5 : VOLUME /tmp
---> Running in aa43baf235ca
Removing intermediate container aa43baf235ca
---> 423688a3a9ac
Step 3/5 : ADD demo1-0.0.1-SNAPSHOT.jar app.jar
---> ab141a560b8a
Step 4/5 : RUN bash -c 'touch /app.jar'
---> Running in 50be93095281
Removing intermediate container 50be93095281
---> 731c8eed60b1
Step 5/5 : ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
---> Running in 6af0288a3a44
Removing intermediate container 6af0288a3a44
---> eb5273196a7e
Successfully built eb5273196a7e
Successfully tagged demo1:latest

6.查看

docker images

7.运行

docker run -d -p 8099:8080 demo1

8.输入地址验证

http://localhost:8099/demo1/

ubuntu18下Docker运行springboot项目的更多相关文章

  1. 使用docker运行springboot项目

    本文主要讲的是使用docker运行springboot项目 获取一个springboot项目 这里我没有重新构建,用的之前写的一个项目,直接从github上下载下来,地址:https://github ...

  2. linux安装docker,并在docker上运行springboot项目

    docker架构示例图 仓库---> 镜像 --->  容器 一.安装docker 1.通过 uname -r 命令查看你当前的内核版本 uname -r 2使用 root 权限登录 Ce ...

  3. linux下后台启动springboot项目

    linux下后台启动springboot项目 我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn p ...

  4. linux下后台启动springboot项目(转载)

    我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn package”进行打包时,会打包成一个可以直接 ...

  5. 使用外部容器运行spring-boot项目:不使用spring-boot内置容器让spring-boot项目运行在外部tomcat容器中

    前言:本项目基于maven构建 spring-boot项目可以快速构建web应用,其内置的tomcat容器也十分方便我们的测试运行: spring-boot项目需要部署在外部容器中的时候,spring ...

  6. SpringBoot(十六)-- 使用外部容器运行springBoot项目

    spring-boot项目需要部署在外部容器中的时候,spring-boot导出的war包无法再外部容器(tomcat)中运行或运行报错. 为了解决这个问题,需要移除springBoot自带的tomc ...

  7. 运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.

    运行springboot项目报错: *************************** APPLICATION FAILED TO START ************************** ...

  8. 报错----运行springboot项目出现:Type javax.xml.bind.JAXBContext not present

    目的:运行springboot项目出现:Type javax.xml.bind.JAXBContext not present 环境: 问题:运行springboot项目出现:Type javax.x ...

  9. 从零开始学习docker之在docker中运行springboot项目

    一.docker环境配置 首先需要一个安装了docker的服务器(本地或者云服务器),如果没有请看上文,传送门---https://www.cnblogs.com/wdfordream/p/12737 ...

随机推荐

  1. c 语言延时函数

    /*--- 等待x毫秒 ---*/ int sleep(unsigned long x) { clock_t c1 = clock(), c2; do { ) /* 错误 */ ; } while ( ...

  2. Node解析之----模块机制篇

    开篇前,我们先来看张图, 看node与W3C组织.CommonJS组织.ECMAScript之间的关系. Node借鉴来CommonJS的Modules规范实现了一套非常易用的模块系统,NPM对Pac ...

  3. JavaScript Call函数原理

    call原理分析,一定要看最后的例子. 1.call使用例子 function add(c, d) { return this.a + this.b + c + d; } , b: }; consol ...

  4. CF1200C

    CF1200C 题意: 问内圆和外圆分别分成n.m份,每份有标号,问是否可以从一个部分走到另一个部分,12点钟位置一定有个线. 解法: 如果有一堵墙贯穿1和2,那么会使得两边不连通.这样的墙会显然出现 ...

  5. hive 常用参数

    hive.exec.max.created.files •说明:所有hive运行的map与reduce任务可以产生的文件的和 •默认值:100000  hive.exec.dynamic.partit ...

  6. 【Linux】安装 PostgreSQL

    参考: CSDN1:https://blog.csdn.net/ctwy291314/article/details/79900074 1.进入 PostgreSQL 官网的下载地址, 2.选择下面的 ...

  7. Nginx 出现 403 Forbidden 最终解决方法

    Nginx 出现 403 Forbidden 最终解决 步骤一: 检查目录权限.权限不足的就加个权限吧. 例子:chmod -R 755 / var/www 步骤二: 打开nginx.conf 例子: ...

  8. Mysql mysqldumpslow命令详解

    mysqldumpslow命令 /path/mysqldumpslow -s c -t 10 /database/mysql/slow-log 这会输出记录次数最多的10条SQL语句. 其中: -s, ...

  9. Thymeleaf th:include、th:replace引用

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" ...

  10. react native Expo适配全面屏/Expo识别全面屏和正常屏

    一.最新版本的expo已经默认支持了全面屏,即不会像react native cli一样出现底部黑边 二.但是全面屏通过Dimensions.get('window')获取的高度还是不准确,因为全面屏 ...