docker compose 編排容器 mysql Springboot應用

寫一個docker-compose.yml文件

內容如下:

services:db:image: "docker.xuanyuan.me/library/mysql:8.3.0"restart: unless-stoppedhostname: dbports:- "3306:3306"container_name: mysqlenvironment:- "MYSQL_ROOT_PASSWORD=1234"myjava:build:context: .ports:- "8080:8080"depends_on:- db

如果拉起鏡像困難可先用pull拉取成功后在執行docker compose

注意新版本命令是docker compose 而不是docker-compose

這樣mysql先啟動,自定義的容器后啟動保證啟動順序

執行docker compose up

[root@localhost ~]# docker compose up
[+] Running 2/2? Container mysql          Created                                                                                         0.1s? Container root-myjava-1  Created                                                                                         0.1s
Attaching to mysql, myjava-1
mysql     | 2025-07-20 01:55:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.3.0-1.el8 started.
mysql     | 2025-07-20 01:55:59+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql     | 2025-07-20 01:55:59+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.3.0-1.el8 started.
mysql     | 2025-07-20 01:56:00+00:00 [Note] [Entrypoint]: Initializing database files
mysql     | 2025-07-20T01:56:00.501879Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
mysql     | 2025-07-20T01:56:00.511825Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.3.0) initializing of server in progress as process 78
mysql     | 2025-07-20T01:56:00.547310Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql     | 2025-07-20T01:56:01.897536Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql     | 2025-07-20T01:56:07.956337Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
myjava-1  |
myjava-1  |   .   ____          _            __ _ _
myjava-1  |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
myjava-1  | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
myjava-1  |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
myjava-1  |   '  |____| .__|_| |_|_| |_\__, | / / / /
myjava-1  |  =========|_|==============|___/=/_/_/_/
myjava-1  |
myjava-1  |  :: Spring Boot ::                (v3.4.7)
myjava-1  |
myjava-1  | 2025-07-20T01:56:14.355Z  INFO 1 --- [demo1] [           main] org.example.demo1.Demo1Application       : Starting Demo1Application v0.0.1-SNAPSHOT using Java 21 with PID 1 (/app/app.jar started by root in /app)
myjava-1  | 2025-07-20T01:56:14.391Z  INFO 1 --- [demo1] [           main] org.example.demo1.Demo1Application       : The following 1 profile is active: "pro"
mysql     | 2025-07-20T01:56:19.730033Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
mysql     | 2025-07-20 01:56:19+00:00 [Note] [Entrypoint]: Database files initialized
mysql     | 2025-07-20 01:56:19+00:00 [Note] [Entrypoint]: Starting temporary server
mysql     | 2025-07-20T01:56:19.854669Z 0 [System] [MY-015015] [Server] MySQL Server - start.
mysql     | 2025-07-20T01:56:20.306879Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.3.0) starting as process 118
mysql     | 2025-07-20T01:56:20.368952Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql     | 2025-07-20T01:56:20.985344Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql     | 2025-07-20T01:56:22.297269Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
mysql     | 2025-07-20T01:56:22.302279Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
mysql     | 2025-07-20T01:56:22.321292Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql     | 2025-07-20T01:56:22.424971Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
mysql     | 2025-07-20T01:56:22.434865Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.3.0'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.
mysql     | 2025-07-20 01:56:22+00:00 [Note] [Entrypoint]: Temporary server started.
mysql     | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
mysql     | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
mysql     | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
mysql     | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
myjava-1  | 2025-07-20T01:56:33.171Z  INFO 1 --- [demo1] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
myjava-1  | 2025-07-20T01:56:33.342Z  INFO 1 --- [demo1] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
myjava-1  | 2025-07-20T01:56:33.354Z  INFO 1 --- [demo1] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.42]
myjava-1  | 2025-07-20T01:56:34.978Z  INFO 1 --- [demo1] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
myjava-1  | 2025-07-20T01:56:35.010Z  INFO 1 --- [demo1] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 19598 ms
myjava-1  | Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
mysql     | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
mysql     | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql     | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
mysql     |
mysql     | 2025-07-20 01:56:53+00:00 [Note] [Entrypoint]: Stopping temporary server
mysql     | 2025-07-20T01:56:53.447182Z 10 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.3.0).
myjava-1  | Get /172.18.0.3 network interface
myjava-1  | Get network interface info: name:eth0 (eth0)
myjava-1  | Initialization Sequence datacenterId:3 workerId:30
myjava-1  |  _ _   |_  _ _|_. ___ _ |    _
myjava-1  | | | |\/|_)(_| | |_\  |_)||_|_\
myjava-1  |      /               |
myjava-1  |                         3.5.12
mysql     | 2025-07-20T01:56:57.288017Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.3.0)  MySQL Community Server - GPL.
mysql     | 2025-07-20T01:56:57.293771Z 0 [System] [MY-015016] [Server] MySQL Server - end.
mysql     | 2025-07-20 01:56:57+00:00 [Note] [Entrypoint]: Temporary server stopped
mysql     |
mysql     | 2025-07-20 01:56:57+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
mysql     |
mysql     | 2025-07-20T01:56:57.544573Z 0 [System] [MY-015015] [Server] MySQL Server - start.
mysql     | 2025-07-20T01:56:58.042930Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.3.0) starting as process 1
mysql     | 2025-07-20T01:56:58.098132Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql     | 2025-07-20T01:56:58.873478Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysql     | 2025-07-20T01:57:00.560040Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
mysql     | 2025-07-20T01:57:00.560764Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
mysql     | 2025-07-20T01:57:00.587610Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql     | 2025-07-20T01:57:00.854363Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
mysql     | 2025-07-20T01:57:00.859520Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.3.0'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
myjava-1  | 2025-07-20T01:57:02.748Z  INFO 1 --- [demo1] [           main] m.e.s.MybatisPlusApplicationContextAware : Register ApplicationContext instances org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1722011b
myjava-1  | 2025-07-20T01:57:03.841Z  INFO 1 --- [demo1] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
myjava-1  | 2025-07-20T01:57:03.999Z  INFO 1 --- [demo1] [           main] org.example.demo1.Demo1Application       : Started Demo1Application in 57.681 seconds (process running for 64.939)
myjava-1  | 2025-07-20T01:57:04.313Z  INFO 1 --- [demo1] [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
myjava-1  | 2025-07-20T01:57:04.316Z  INFO 1 --- [demo1] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
myjava-1  | 2025-07-20T01:57:04.336Z  INFO 1 --- [demo1] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms

有關自定義鏡像參考上一篇文章

docker構建springboot鏡像-CSDN博客

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/89827.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/89827.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/89827.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

React 中 props 的最常用用法精選+useContext

? React 最常用 props 用法 10 例? 1. 傳遞字符串 / 數字 / 布爾值function UserCard({ name, age, isVip }) {return (<div>{name} - {age} - {isVip ? VIP : 普通用戶}</div>); }<UserCard name"張三" age{18} isVip{true} />? 2. 傳遞函數&…

離散型制造企業的可視化破局:設備OEE動態看板與工藝路徑模擬實踐

內容摘要離散型制造企業面臨著設備效率低下、生產過程不透明、工藝路徑復雜等諸多挑戰。如何通過可視化手段提升設備效率和生產透明度&#xff0c;成為企業亟待解決的問題。設備整體效率&#xff08;OEE&#xff09;動態看板和工藝路徑模擬是兩個關鍵的可視化工具&#xff0c;能…

在Tailwind Css中如何書寫flex布局

僅供參考 文章目錄一、啟用 flex 布局二、行內 flex 布局三、方向控制四、對齊方式五、子元素控制1、控制子元素的寬度是否可伸縮2、控制子元素順序3、控制子元素間的間隙4、控制子元素是否可換行顯示一、啟用 flex 布局 設置 class“flex” 啟用 flex 布局 <template>…

交通出行大前端與 AI 融合:智能導航與出行預測

交通出行類大前端應用&#xff08;導航APP、打車軟件、公交地鐵小程序等&#xff09;是連接用戶與出行服務的核心載體&#xff0c;其核心價值在于“高效規劃路徑、精準規避擁堵、適配個性化需求”。傳統導航依賴固定規則&#xff08;如“最短路徑優先”&#xff09;和歷史數據&…

csc(x)積分推導

在MATLAB中同時繪制 sin?(x), csc(x) 和 ln?∣tan?(x/2)∣的函數圖像&#xff0c;需要處理函數的奇點&#xff08;如 csc?(x) 在 sin?(x)0 時無定義&#xff0c;ln?∣tan?(x/2)∣ 在 xkπ 時無定義&#xff09;&#xff08;deepseek生成matlab代碼&#xff09;% 定義x范…

rtsp協議之.c++實現,rtsp,rtp協議框架,模擬多路音視頻h264,265,aac,數據幀傳輸,接收(二)

rtsp協議之.c實現&#xff0c;rtsp&#xff0c;rtp協議框架&#xff0c;模擬多路音視頻h264&#xff0c;265&#xff0c;aac&#xff0c;數據幀傳輸&#xff0c;接收&#xff08;二&#xff09; 1、RTSP 服務器核心&#xff1a;處理 RTSP 會話管理、請求解析和響應生成 2、媒體…

網絡性能與應用性能的協同優化研究:基于小波變換與CNN的圖像分類系統

網絡性能與應用性能的協同優化研究&#xff1a;基于小波變換與CNN的圖像分類系統 前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家。點擊跳轉到網站。 摘要 本文研究了網絡性能&#xff08;延遲、帶寬、丟…

【網絡安全領域】CTF競賽指南:賽事詳解、熱門平臺與信息獲取方式

CTF&#xff08;Capture The Flag&#xff09;&#xff0c;中文稱為奪旗賽&#xff0c;是網絡安全領域中一種備受關注和歡迎的競賽形式。以下是關于 CTF 競賽的詳細介紹&#xff0c;以及一些參賽平臺和相關咨詢途徑&#xff1a; CTF 競賽詳解 起源&#xff1a;CTF 起源于 199…

進程(以及系統調用和庫函數概念)

計算機管理硬件&#xff1a;先去組織起來再去描述起來&#xff08;類比先去組織小組&#xff0c;再去詳細描述工作&#xff09;系統調用和庫函數概念&#xff1a;系統就像是銀行&#xff0c;會去防著我們&#xff0c;但是會釋放一些接口用于我們使用&#xff0c;這個就是叫做系…

linux + 寶塔面板 部署 django網站 啟動方式:uwsgi 和gunicorn如何選擇 ?

啟動方式:uwsgi 和gunicorn如何選擇 ? 項目uWSGIGunicorn協議uWSGI 協議&#xff08;可用 HTTP/socket&#xff09;HTTP 協議啟動方式命令或 .ini 配置文件命令參數或 systemd 配置兼容框架支持 WSGI、uWSGI、FastCGI 等僅支持 WSGI性能高性能、極可調高性能、默認參數也夠用配…

基于有監督學習的主動攻擊檢測系統

核心功能&#xff1a;登錄注冊功能主儀表板功能&#xff1a;實時展示檢測結果和圖表分析&#xff0c;模型準確率、攻擊次數等。數據管理功能&#xff1a;加載訓練數據、預處理數據&#xff08;使用開源KDD數據集做為模型訓練數據)。模型訓練功能&#xff1a;支持隨機森林、支持…

simulink系列之模型接口表生成及自動連線腳本

總目錄 simulink系列之汽車應用層信號處理 第一章 simulink信號處理——debounce 第二章 simulink接口表生成及自動連線腳本 目錄 前言 一、simulink接口表生成腳本 1.使用方法&#xff1a; 二、模型整理連線腳本 1.使用方法&#xff1a; 總結 前言 本系列主要圍繞作者采用si…

Eureka+LoadBalancer實現服務注冊與發現

目錄 一、相關文章 二、兼容說明 三、服務注冊到EurekaServer 四、服務發現 五、LoadBalancer負載均衡 一、相關文章 基礎工程&#xff1a;gradle7.6.1springboot3.2.4創建微服務工程-CSDN博客 Eureka服務端啟動&#xff1a;Eureka服務端啟動-CSDN博客 LoadBalancer官方…

數據存儲方案h5py

對于百萬級別的大規模數據&#xff08;假設 N > 1,000,000&#xff09;&#xff0c;在保證讀取速度的前提下&#xff0c;需要綜合考慮 存儲效率、I/O 吞吐 和 內存管理。以下是針對超大規模數據的優化方案&#xff1a;&#x1f680; 終極方案&#xff1a;HDF5 (h5py) 分塊存…

ARINC818協議綜述

概要 航天領域ARINC818協議 協議的視頻幀 協議的層次 幀格式 容器 FC協議的5個層次 8b10b編碼 SOF EOF IDLEARINC818視頻傳輸協議 ARINC818協議的容器系統 幀頭控制協議FHCP 光纖通道協議 FC-AV ARINC818行場同步解析&#xff0c;上圖時序圖是關于行場同步小信號相關。ARINC818…

專題 二分法:查找與判定

概念解釋 概述 二分法在算法競賽中一般有這么一個用途&#xff1a;在一個具有單調性的解空間中找到符合題意的一個可行解。下面解釋幾個專有名詞&#xff1a; 解空間 很簡單&#xff0c;就是可能存在解的邏輯區域。這個在算法入門時應提到。 可行解 符合題意的解 單調性 …

硬核電子工程:從硅片到系統的全棧實戰指南—— 融合電路理論、嵌入式開發與PCB設計的工程藝術

一、電路基礎&#xff1a;硬件設計的底層邏輯1.1 基爾霍夫定律的硬件實現// STM32驗證KVL定律&#xff08;ADC采樣法&#xff09; void verify_kvl() {ADC_Enable(ADC1); // 啟用ADCfloat Vr1 read_ADC(PA0) * 3.3 / 4096; // 讀取R1電壓float Vr2 read_ADC(PA1) * 3.3 / 4…

Linux網絡:序列化與反序列化

引入&#xff1a;面向字節流 TCP是面向字節流的&#xff0c;如果按照字節流來讀取信息&#xff0c;可能會出問題 比如客戶傳入“1100”&#xff0c;服務器讀入“11”&#xff0c;后面的00被當作下一條信息&#xff0c;這就出問題了 我們可以將多個信息合并為一個字符串 在發送信…

二、Spark 開發環境搭建 IDEA + Maven 及 WordCount 案例實戰

作者&#xff1a;IvanCodes 日期&#xff1a;2025年7月20日 專欄&#xff1a;Spark教程 本教程將從零開始&#xff0c;一步步指導您如何在 IntelliJ IDEA 中搭建一個基于 Maven 和 Scala 的 Spark 開發環境&#xff0c;并最終完成經典的 WordCount 案例。 一、創建 Maven 項目…

【python】算法實現1

實現一個動態規劃算法 def dynamic_programming_example(n: int) -> List[int]:"""動態規劃示例&#xff1a;計算斐波那契數列參數:- n: 斐波那契數列的項數返回:- List[int]: 斐波那契數列前n項"""if n < 0:return []elif n 1:return […