另一種辦法直接在宿主機(jī)上的文件夾內(nèi)查看Docker鏡像運(yùn)行的日志文件

      網(wǎng)友投稿 1560 2025-04-01

      我們可以用docker ps首先找到某個(gè)Docker容器的id,再使用關(guān)鍵字docker logs <容器id>打印出該容器產(chǎn)生的日志:


      同樣,在宿主機(jī)目錄/var/lib/docker/containers下面,能發(fā)現(xiàn)一個(gè)文件夾,其前12位名稱正好是我們在命令docker ps里查看到的容器id:

      進(jìn)入該文件夾,即可查找到以-json.log結(jié)尾的日志文件:

      如何將SpringBoot應(yīng)用Docker化并部署到SAP云平臺?

      首先需要把SpringBoot應(yīng)用打包成docker,我用的dockerfile內(nèi)容為:

      FROM openjdk:8-jdk-alpine

      VOLUME /tmp

      VOLUME /log

      EXPOSE 8080

      ADD target/prolikeService.jar app.jar

      ENV JAVA_OPTS="-Dserver.port=8080"

      ENTRYPOINT exec java $JAVA_OPTS -jar /app.jar

      使用如下的命令行打包:

      docker build -t i042416/springbootexample:v4 .

      docker login登錄docker hub,將該鏡像上傳:

      docker push i042416/springbootexample:v4

      最后使用命令部署到SAP Cloud Platform上:

      cf push jerryjavadocker --docker-image i042416/springbootexample:v4

      命令執(zhí)行完畢后,能夠在SAP云平臺的控制臺里,看到這個(gè)成功部署的Docker應(yīng)用:

      從控制臺里得到應(yīng)用url:

      成功訪問:

      SpringBoot里的官方文檔叫做Externalized Configuration:

      優(yōu)先級依次如下:

      (1) Devtools global settings properties in the $HOME/.config/spring-boot folder when devtools is active.

      (2) @TestPropertySource annotations on your tests.

      (3) properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your Application.

      (4) Command line arguments.

      (5) Properties from SPRING_Application_JSON (inline JSON embedded in an environment variable or system property).

      (6) ServletConfig init parameters.

      (7) ServletContext init parameters.

      (8) JNDI attributes from java:comp/env.

      (9) Java System properties (System.getProperties()).

      (10) OS environment variables.

      (11) A RandomValuePropertySource that has properties only in random.*.

      (12) Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).

      (13) Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).

      另一種辦法直接在宿主機(jī)上的文件夾內(nèi)查看Docker鏡像運(yùn)行的日志文件

      (14) Application properties outside of your packaged jar (application.properties and YAML variants).

      (15) Application properties packaged inside your jar (application.properties and YAML variants).

      (16) @PropertySource annotations on your @Configuration classes. Please note that such property sources are not added to the Environment until the application context is being refreshed. This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.

      (17) Default properties (specified by setting SpringApplication.setDefaultProperties).

      做個(gè)實(shí)驗(yàn),在run as configuration里,program argument設(shè)置為server.port=8001,

      Environment環(huán)境變量設(shè)置為server.port=8002.

      在SpringBoot項(xiàng)目內(nèi)部的Application.properties文件設(shè)置成8000:

      最后運(yùn)行時(shí),生效的端口是環(huán)境變量設(shè)置進(jìn)去的8002:

      在shell里使用set命令設(shè)置環(huán)境變量,也能按照期望的方式工作:

      Docker 鏡像服務(wù)

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:常用項(xiàng)目管理軟件有哪些
      下一篇:“智能、高效,一體化”的城市配送平臺
      相關(guān)文章
      亚洲精品美女久久久久99小说| 亚洲国产超清无码专区| 亚洲成人福利在线观看| 亚洲精品乱码久久久久久自慰| 亚洲情a成黄在线观看| 国产av无码专区亚洲av毛片搜 | 亚洲一卡2卡4卡5卡6卡在线99| 亚洲综合在线成人一区| 亚洲韩国—中文字幕| 亚洲第一中文字幕| 亚洲AV第一页国产精品| 亚洲AV天天做在线观看| 久久久亚洲欧洲日产国码农村| 久久国产精品亚洲一区二区| 精品亚洲综合久久中文字幕| 国产精品亚洲精品日韩已满| 亚洲国产日韩在线视频| 亚洲va无码va在线va天堂| 久久久久亚洲精品美女| 亚洲国产天堂在线观看| 亚洲色大成网站www永久| 91亚洲视频在线观看| 亚洲乱码卡一卡二卡三| 亚洲 欧洲 自拍 另类 校园| 亚洲欧美日韩综合久久久久| 亚洲成av人无码亚洲成av人| 狠狠入ady亚洲精品| 亚洲精品无码久久不卡| 亚洲综合日韩久久成人AV| 国产国拍亚洲精品mv在线观看 | 亚洲中文字幕久久精品无码A| 亚洲国产精品无码久久久秋霞1| 亚洲AV成人精品一区二区三区 | 亚洲精品国产福利片| 亚洲综合丁香婷婷六月香| 亚洲字幕AV一区二区三区四区| 亚洲爆乳无码专区www| 亚洲av无码成人精品区| 亚洲精品无码久久毛片| 亚洲精品无码久久千人斩| 亚洲伊人tv综合网色|