前言
项目需要:
安装Dockeridea中安装docker插件,并配置docker一个SpringBoot项目创建Dockerfile
一、下载、安装、配置Docker下载Docker
下载地址:官网下载 Docker
安装
一直下一步就行
配置路径:Settings–General 勾选 Expose daemon on tcp://localhost:2375 without TLS
设置镜像,提高下载镜像的速度https://xaiqlt1z.mirror.aliyuncs.com
测试是否安装成功
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 安装
2.配置Docker服务
file – 搜索docker – 选择Docker – 右侧添加一个Docker
Connection successful 显示,表示 Docker链接成功
三、创建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打包后复制进来的。
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配置
运行
运行成功
测试
使用docker 检查容器是否启动:
测试项目是否启动:
总结
今天学了下Docker容器,基本的命令学会了,但是一直没弄懂怎么使用。借此机会就花费时间进行学习。目前只是会用,后面会补上步骤详细描述。
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
- 《饿殍:明末千里行》行将就木的日月山河
- 【古典音乐】卡拉扬《马勒·大地之歌》2013[FLAC+CUE/整轨]
- KOKIA《EVOLVEtoLOVE20周年精逊4CD【FLAC】
- 李娜(昌圣法师)-《唱经给你听.念佛礼仪》[APE]
- 前《龙腾世纪》编剧谈EA用AI做游戏:他们的兴奋是绝望的哀嚎
- 世界公认最丑的鱼登热搜 科普:其实是人为被迫毁容
- 网易新作合约要求测试者不准说坏话:现已撤回并道歉
- 【原神】V4.6攻略 | 全角色突破用讨伐材料汇总
- 【原神】V4.6攻略 | 4.6版本下半抽卡建议
- 【原神】V4.6攻略 | 那维莱特的一条龙机制介绍、养成及配队
- 郑智化.1995-游戏人间【飞碟】【WAV+CUE】
- 群星.1999-唱好香港【STAREAST】【WAV+CUE】
- 美宝.2013-从目的地出发【金牌大风】【WAV+CUE】
- 新生 New Life
- 站长 Chief of Station