Docker部署Nacos-v2.4.1适配金仓无需重构项目及打包镜像的方法

发布时间:2026/7/17 4:27:46
Docker部署Nacos-v2.4.1适配金仓无需重构项目及打包镜像的方法 场景使用国产数据库,本地测试环境使用docker快速部署,但nacos改造起来费时费力,还需要重新构建镜像,故采用一些投机取巧的方法操作方案1.配置docker-compose.yml文件nacos: image: nacos/nacos-server:v2.4.1 restart: always container_name: nacos ports: - 9895:8848 - 10985:9848 - 10986:9849 environment: - PREFER_HOST_MODEhostname - MODEstandalone - TZAsia/Shanghai - DB_POOL_CONFIG_DRIVERCLASSNAMEcom.kingbase8.Driver volumes: - ./nacos/data:/home/nacos/data - ./nacos/logs:/home/nacos/logs - ./nacos/conf/application.properties:/home/nacos/conf/application.properties - ./nacos/libs/kingbase8-8.6.0.jar:/home/nacos/plugins/kingbase8-8.6.0.jar networks: - your_network2.编写配置文件application.properties#*************** Spring Boot Related Configurations ***************# ### Default web context path: server.servlet.contextPath/nacos ### Include message field server.error.include-messageON_PARAM ### Default web server port: server.port8848 #*************** Network Related Configurations ***************# #*************** Config Module Related Configurations 配置数据库链接信息 ***************# nacos.core.server.grpc.port9848 nacos.core.server.grpc.client.port9849 ### If use MySQL as datasource: #### 这里的值就是mysql,不要改成kingbase,会报错 spring.datasource.platformmysql ### Count of DB: db.num1 ### Connect URL of DB: db.url.0jdbc:kingbase8://your_ip:your_port/your_db?useUnicodetruecharacterEncodingutf8zeroDateTimeBehaviorconvertToNulluseSSLfalseserverTimezoneGMT%2B8?allowEncodingChangestrueclientEncodingUTF8 db.user.0your_user db.password.0your_password nacos.naming.empty-service.auto-cleantrue nacos.naming.empty-service.clean.initial-delay-ms50000 nacos.naming.empty-service.clean.period-time-ms30000 #*************** Metrics Related Configurations ***************# ### Metrics for prometheus #management.endpoints.web.exposure.include* ### Metrics for elastic search management.metrics.export.elastic.enabledfalse #management.metrics.export.elastic.hosthttp://localhost:9200 ### Metrics for influx management.metrics.export.influx.enabledfalse #*************** Access Log Related Configurations ***************# ### If turn on the access log: server.tomcat.accesslog.enabledtrue ### The access log pattern: server.tomcat.accesslog.pattern%h %l %u %t %r %s %b %D %{User-Agent}i %{Request-Source}i ### The directory of access log: server.tomcat.basedirfile:. #*************** Access Control Related Configurations ***************# ### If enable spring security, this option is deprecated in 1.2.0: #spring.security.enabledfalse ### The ignore urls of auth, is deprecated in 1.2.0: nacos.security.ignore.urls/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** ### The auth system to use, currently only nacos and ldap is supported: nacos.core.auth.system.typenacos ### If turn on auth system: nacos.core.auth.enabledtrue ### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay. nacos.core.auth.caching.enabledtrue ### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version. nacos.core.auth.enable.userAgentAuthWhitefalse ### Since 1.4.1, worked when nacos.core.auth.enabledtrue and nacos.core.auth.enable.userAgentAuthWhitefalse. ### The two properties is the white list for auth and used by identity the request from other server. nacos.core.auth.server.identity.keyserverIdentity nacos.core.auth.server.identity.valuesecurity ### worked when nacos.core.auth.system.typenacos ### The token expiration in seconds: nacos.core.auth.plugin.nacos.token.expire.seconds18000 ### The default token: nacos.core.auth.plugin.nacos.token.secret.keySecretKey012345678901234567890123456789012345678901234567890123456789 ### worked when nacos.core.auth.system.typeldap{0} is Placeholder,replace login username #*************** Istio Related Configurations ***************# ### If turn on the MCP server: nacos.istio.mcp.server.enabledfalse #*************** Core Related Configurations ***************#3.将kingbase8的驱动jar包导入到挂载目录中自己在网上下一个也行,或者 du盘链接: /s/1aeLXDFD5xaCBW7QEBXrBsQ?pwdhvit 提取码: hvit4.适配kingbase的nacos初始化脚本直接下载就行链接: nacos适配kingbase初始化脚本或者 du盘链接: /s/1aeLXDFD5xaCBW7QEBXrBsQ?pwdhvit 提取码: hvit5.启动docker容器验证即可6.参考:国产化数据库达梦DM、人大金仓kingbase8部署基于Docker的Nacos服务不需修改nacos源码_国产化部署需要哪些服务-CSDN博客Nacos docker 版本配置kingbase 人大金仓 达梦 数据库_nacos kingbase-CSDN博客