DDR爱好者之家 Design By 杰米

前言

项目需要:

安装Dockeridea中安装docker插件,并配置docker一个SpringBoot项目创建Dockerfile

一、下载、安装、配置Docker下载Docker

下载地址:官网下载 Docker

安装

一直下一步就行

配置路径:Settings–General 勾选 Expose daemon on tcp://localhost:2375 without TLS

在Idea中使用Docker部署SpringBoot项目的详细步骤

设置镜像,提高下载镜像的速度https://xaiqlt1z.mirror.aliyuncs.com

在Idea中使用Docker部署SpringBoot项目的详细步骤

测试是否安装成功

C:\Users\msi>docker -v
Docker version 19.03.12, build 48a66213fe

C:\Users\msi> docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  (amd64)
 3. The Docker daemon created a new container from that image which runs the
  executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
  to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

二、Idea 安装Docker插件

1.安装docker插件在idea中: file--Plugins--Marketplace 搜索 Docker 安装

在Idea中使用Docker部署SpringBoot项目的详细步骤

2.配置Docker服务

file – 搜索docker – 选择Docker – 右侧添加一个Docker
Connection successful 显示,表示 Docker链接成功

在Idea中使用Docker部署SpringBoot项目的详细步骤

三、创建SpringBoot项目,修改pom.xmlspringMVC 项目,访问 localhost:8080/hello 显示 hello 字符串

@RequestMapping("/hello")
  @ResponseBody
  public String hello () {
    return "hello";
  }

1.配置pom.xml 文件

<build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version> 1.2.1</version>
        <executions>
          <execution>
            <id>build-image</id>
            <phase>package</phase>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <imageName>${project.artifactId}</imageName>
          <imageTags>
            <imageTag>latest</imageTag>
          </imageTags>
          <dockerDirectory>${project.basedir}</dockerDirectory>
          <dockerHost>http://localhost:2375</dockerHost>
          <resources>
            <resource>
              <targetPath>/</targetPath>
              <directory>${project.build.directory}</directory>
              <include>${project.build.finalName}</include>
            </resource>
          </resources>
        </configuration>
      </plugin>
    </plugins>
  </build>

2.创建Docker 文件

在main文件夹下创建一个docker文件夹,并在里面创建一个Dockerfile文件。xxxxx.jar 是使用maven打包后复制进来的。

在Idea中使用Docker部署SpringBoot项目的详细步骤

Dockerfile 文件内容:

# From java image, version : 8
FROM java:8

# 挂载app目录
VOLUME /app

# COPY or ADD to image
COPY demo-0.0.1-SNAPSHOT.jar app.jar

RUN bash -c "touch /app.jar"
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

maven打包,将其target目录下的jar包复制进docker目录下。

配置Dockerfile配置

在Idea中使用Docker部署SpringBoot项目的详细步骤

运行

在Idea中使用Docker部署SpringBoot项目的详细步骤

运行成功

在Idea中使用Docker部署SpringBoot项目的详细步骤

测试

使用docker 检查容器是否启动:

在Idea中使用Docker部署SpringBoot项目的详细步骤

测试项目是否启动:

在Idea中使用Docker部署SpringBoot项目的详细步骤

总结

今天学了下Docker容器,基本的命令学会了,但是一直没弄懂怎么使用。借此机会就花费时间进行学习。目前只是会用,后面会补上步骤详细描述。

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。