国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

使用docker Maven插件本地構建docker鏡像并發布到遠程服務器

jcc / 3297人閱讀

摘要:登錄網站,生成一個基本的應用。將應用導入并創建類。連接,執行命令,查看可用的鏡像執行命令,使用鏡像啟動容器。至此,使用插件構建鏡像并運行容器完成,訪問路徑,獲得結果

1.登錄網站https://start.spring.io/,生成一個基本的SpringBoot應用。

2.將應用導入Eclipse IDE并創建Application類。目錄結構如下:

Application代碼如下:

package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class Application {
    
    @RequestMapping(value="/phone")
    public String index(){
        return "Hello World!";
    }
}

3.在pom.xml文件中增加插件配置:


            
                com.spotify
                docker-maven-plugin
                0.4.12
                
                    
                    
                    microservice-eureka-demo
                    java
                    ["java", "-jar", "/${project.build.finalName}.jar"]
                    
                        
                            /
                            ${project.build.directory}
                            ${project.build.finalName}.jar
                        
                    
                
            

4.pom.xml文件中增加依賴:

          
            org.springframework.boot  
            spring-boot-starter-web  
        

5.配置本地環境變量,設置docker文件構建主機(主機192.168.244.130已經安裝完docker環境)

root@ubuntu-02:~# docker -v
Docker version 17.05.0-ce, build 89658be

本地環境變量配置如下:

6.進入代碼目錄,執行命令“mvn clean package docker:build”項目編譯成功。

[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ dockerdemo ---
[INFO] Building jar: C:UsersSeanDownloadsdemodemo	argetdockerdemo-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ dockerdemo ---
[INFO]
[INFO] --- docker-maven-plugin:0.4.12:build (default-cli) @ dockerdemo ---
[INFO] Copying C:UsersSeanDownloadsdemodemo	argetdockerdemo-0.0.1-SNAPSHOT.jar -> C:UsersSeanDownloadsdemodemo	argetdockerdockerdemo-0.0.1-SNAPSHOT.jar
[INFO] Building image microservice-eureka-demo
Step 1/3 : FROM java
 ---> d23bdf5b1b1b
Step 2/3 : ADD /dockerdemo-0.0.1-SNAPSHOT.jar //
 ---> e1b3c3de711c
Removing intermediate container a9e57b1d9883
Step 3/3 : ENTRYPOINT java -jar /dockerdemo-0.0.1-SNAPSHOT.jar
 ---> Running in 7a3cdc1d112b
 ---> 1f800bf8cb24
Removing intermediate container 7a3cdc1d112b
Successfully built 1f800bf8cb24
Successfully tagged microservice-eureka-demo:latest
[INFO] Built microservice-eureka-demo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.982 s
[INFO] Finished at: 2017-07-23T21:51:21+08:00
[INFO] Final Memory: 42M/393M
[INFO] ------------------------------------------------------------------------

7.ssh連接192.168.244.130,執行命令“docker images”,查看可用的鏡像:

root@ubuntu-02:~# docker images
REPOSITORY                                                           TAG                 IMAGE ID            CREATED             SIZE
microservice-eureka-demo                                             latest              1f800bf8cb24        23 minutes ago      658MB

8.執行命令“docker run -p 8080:8080 microservice-eureka-demo:latest”,使用鏡像microservice-eureka-demo:latest啟動docker容器。

root@ubuntu-02:~# docker run -p 8080:8080 microservice-eureka-demo:latest

  .   ____          _            __ _ _
 / / ___"_ __ _ _(_)_ __  __ _    
( ( )\___ | "_ | "_| | "_ / _` |    
 /  ___)| |_)| | | | | || (_| |  ) ) ) )
  "  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.4.RELEASE)

2017-07-23 14:19:21.766  INFO 1 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on 656842f890d3 with PID 1 (/dockerdemo-0.0.1-SNAPSHOT.jar started by root in /)
2017-07-23 14:19:21.792  INFO 1 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2017-07-23 14:19:22.402  INFO 1 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5a2e4553: startup date [Sun Jul 23 14:19:22 UTC 2017]; root of context hierarchy
2017-07-23 14:19:31.950  INFO 1 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-23 14:19:32.015  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-07-23 14:19:32.032  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-23 14:19:32.467  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-07-23 14:19:32.467  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 10082 ms
2017-07-23 14:19:33.101  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: "dispatcherServlet" to [/]
2017-07-23 14:19:33.141  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: "characterEncodingFilter" to: [/*]
2017-07-23 14:19:33.148  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: "hiddenHttpMethodFilter" to: [/*]
2017-07-23 14:19:33.161  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: "httpPutFormContentFilter" to: [/*]
2017-07-23 14:19:33.161  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: "requestContextFilter" to: [/*]
2017-07-23 14:19:34.708  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5a2e4553: startup date [Sun Jul 23 14:19:22 UTC 2017]; root of context hierarchy
2017-07-23 14:19:35.105  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/phone]}" onto public java.lang.String com.example.demo.controller.Application.index()
2017-07-23 14:19:35.127  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-07-23 14:19:35.138  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-07-23 14:19:35.277  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-23 14:19:35.285  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-23 14:19:35.466  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-23 14:19:36.180  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-23 14:19:36.449  INFO 1 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-23 14:19:36.477  INFO 1 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 17.363 seconds (JVM running for 19.474)

9.執行命令“docker ps”,查看啟動的docker容器。

root@ubuntu-02:~# docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                    NAMES
08099bd4b8e1        microservice-eureka-demo:latest   "java -jar /docker..."   27 seconds ago      Up 26 seconds       0.0.0.0:8080->8080/tcp   upbeat_borg

10.執行命令“docker exec -it 08099bd4b8e1 bin/bash”,進入docker容器。

root@ubuntu-02:~# docker exec -it 08099bd4b8e1 bin/bash 
root@08099bd4b8e1:/# 

11.執行命令“ps -ef”,可用查看到docker容器里面啟動的進程,即是pom.xml配置文件中配置的插件docker-maven-plugin的entryPoint,java -jar /dockerdemo-0.0.1-SNAPSHOT.jar。

["java", "-jar", "/${project.build.finalName}.jar"]

root@08099bd4b8e1:/# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  4 14:20 ?        00:00:17 java -jar /dockerdemo-0.0.1-SNAPSHOT.jar
root         34      0  0 14:24 ?        00:00:00 bin/bash
root         41     34  0 14:26 ?        00:00:00 ps -ef
root@08099bd4b8e1:/#

12.至此,使用docker插件構建docker鏡像并運行docker容器完成,訪問路徑“http://192.168.244.130:8080/p...”,獲得controller結果:

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/26992.html

相關文章

  • 使用docker Maven插件本地構建docker鏡像發布遠程務器

    摘要:登錄網站,生成一個基本的應用。將應用導入并創建類。連接,執行命令,查看可用的鏡像執行命令,使用鏡像啟動容器。至此,使用插件構建鏡像并運行容器完成,訪問路徑,獲得結果 1.登錄網站https://start.spring.io/,生成一個基本的SpringBoot應用。 2.將應用導入Eclipse IDE并創建Application類。目錄結構如下: showImg(https://s...

    Thanatos 評論0 收藏0
  • Jenkins集成Docker鏡像實現自動發布

    摘要:集群環境的部署方式使用集群管理工具通過版本新增文件實現滾動升級容器等同于應用的部署 1. 思路&流程 Jenkins集成Docker鏡像實現自動發布與Jenkins發布mavne項目思路一樣總體流程 為:Jenkins 拉去遠端源碼 —— gitl實現應用打包 —— jenkins本地把應用程序打包進Docker鏡像 ...

    defcon 評論0 收藏0
  • 解放雙手 | Jenkins + gitlab + maven 自動打包部署項目

    摘要:什么是可以簡單地理解為可以代替你實現自動從拉取代碼,打包,部署到遠程服務器的工具。隨后登錄后發現頁面空白,沒找到具體原因,重啟下容器后再登錄就好了。主要是配置訪問服務器拉取代碼,還有配置遠程服務器地址,目的是為了打包后上傳文件到遠程服務器。 showImg(https://segmentfault.com/img/remote/1460000017907307?w=495&h=300)...

    JouyPub 評論0 收藏0

發表評論

0條評論

jcc

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<