# 国内能拉取的 OpenJDK 17
FROM temurin:17-jre-alpine
LABEL maintainer="yourname"
# 时区 & 国内 apk 源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk add --no-cache tzdata curl && \
ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
WORKDIR /app
COPY ruoyi-auth.jar app.jar
# 创建非root用户运行
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
chown -R appuser:appgroup /app
USER appuser
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \
CMD curl -f http://localhost:${SERVER_PORT:-28200}/actuator/health || exit 1
# === 仅设置必要的默认值,其他全部通过环境变量注入 ===
ENV SPRING_PROFILES_ACTIVE=docker
EXPOSE 28200
# 使用shell形式以便环境变量替换
ENTRYPOINT java \
-Djava.security.egd=file:/dev/./urandom \
-Dserver.port=${SERVER_PORT:-28200} \
-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE:-docker} \
-Dspring.cloud.nacos.discovery.server-addr=${NACOS_HOST:-127.0.0.1}:${NACOS_PORT:-8848} \
-Dspring.cloud.nacos.config.server-addr=${NACOS_HOST:-127.0.0.1}:${NACOS_PORT:-8848} \
-Dspring.cloud.nacos.discovery.namespace=${NACOS_NAMESPACE:-public} \
-Dspring.cloud.nacos.config.namespace=${NACOS_NAMESPACE:-public} \
-Dspring.cloud.nacos.discovery.username=${NACOS_USER:-nacos} \
-Dspring.cloud.nacos.config.username=${NACOS_USER:-nacos} \
-Dspring.cloud.nacos.discovery.password=${NACOS_PASS:-nacos} \
-Dspring.cloud.nacos.config.password=${NACOS_PASS:-nacos} \
-Djasypt.encryptor.algorithm=${JASYPT_ALGORITHM:-PBEWITHMD5ANDDES} \
-Dspring.cloud.nacos.config.retry.timeout=30000 \
-Dspring.cloud.nacos.discovery.fail-fast=true \
-DnamingLoadCacheAtStart=false \
-jar app.jar 这是我得dockerfile 以下是报错信息[root@master ~]# kubectl logs -f nacos-standalone-78866b79d4-l69sb -n nacos
+ export CUSTOM_SEARCH_NAMES=application
+ CUSTOM_SEARCH_NAMES=application
+ export CUSTOM_SEARCH_LOCATIONS=file:/home/nacos/conf/
+ CUSTOM_SEARCH_LOCATIONS=file:/home/nacos/conf/
+ export MEMBER_LIST=
+ MEMBER_LIST=
+ PLUGINS_DIR=/home/nacos/plugins/peer-finder
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 '
+ [[ standalone == \s\t\a\n\d\a\l\o\n\e ]]
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true'
+ [[ all == \c\o\n\f\i\g ]]
+ [[ all == \n\a\m\i\n\g ]]
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]
+ [[ ! -z false ]]
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false'
+ [[ ip == \h\o\s\t\n\a\m\e ]]
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list='
++ /usr/lib/jvm/java-1.8.0-openjdk/bin/java -version
++ sed -E -n 's/.* version "([0-9]*).*$/\1/p'
+ JAVA_MAJOR_VERSION=1
+ [[ 1 -ge 9 ]]
+ JAVA_OPT_EXT_FIX=-Djava.ext.dirs=/usr/lib/jvm/java-1.8.0-openjdk/jre/lib/ext:/usr/lib/jvm/java-1.8.0-openjdk/lib/ext
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar '
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/nacos/conf/'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/nacos/conf/ --spring.config.name=application'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/nacos/conf/ --spring.config.name=application --logging.config=/home/nacos/conf/nacos-logback.xml'
+ JAVA_OPT=' -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/nacos/conf/ --spring.config.name=application --logging.config=/home/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288'
+ echo 'Nacos is starting, you can docker logs your container'
+ exec /usr/lib/jvm/java-1.8.0-openjdk/bin/java -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -Xms400m -Xmx400m -Xmn512m -Dnacos.standalone=true -Dnacos.core.auth.enabled=false -Dnacos.member.list= -Xloggc:/home/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/nacos/plugins,/home/nacos/plugins/health,/home/nacos/plugins/cmdb,/home/nacos/plugins/selector -Dnacos.home=/home/nacos -jar /home/nacos/target/nacos-server.jar --spring.config.additional-location=file:/home/nacos/conf/ --spring.config.name=application --logging.config=/home/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
Nacos is starting, you can docker logs your container
OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
OpenJDK 64-Bit Server VM warning: MaxNewSize (524288k) is equal to or greater than the entire heap (409600k). A new max generation size of 409536k will be used.
,--.
,--.'|
,--,: : | Nacos 2.3.2
,`--.'`| ' : ,---. Running in stand alone mode, All function modules
| : : | | ' ,'\ .--.--. Port: 8848
: | \ | : ,--.--. ,---. / / | / / ' Pid: 1
| : ' '; | / \ / \. ; ,. :| : /`./ Console: http://10.244.2.63:8848/nacos/index.html
' ' ;. ;.--. .-. | / / '' | |: :| : ;_
| | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io
' : | ; .' ," .--.; |' ; :__| : | `----. \
| | '`--' / / ,. |' | '.'|\ \ / / /`--' /
' : | ; : .' \ : : `----' '--'. /
; |.' | , .-./\ \ / `--'---'
'---' `--`---' `----'
2025-11-16 19:53:07,267 INFO Tomcat initialized with port(s): 8848 (http)
2025-11-16 19:53:07,372 INFO Root WebApplicationContext: initialization completed in 5196 ms
2025-11-16 19:53:18,185 INFO Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@2b037cfc, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@44924587, org.springframework.security.web.context.SecurityContextPersistenceFilter@688d411b, org.springframework.security.web.header.HeaderWriterFilter@7569ea63, org.springframework.security.web.csrf.CsrfFilter@44a6a68e, org.springframework.security.web.authentication.logout.LogoutFilter@6ff6efdc, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@859ea42, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2af46afd, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@18460128, org.springframework.security.web.session.SessionManagementFilter@16c587de, org.springframework.security.web.access.ExceptionTranslationFilter@2f66f0d0]
2025-11-16 19:53:18,905 INFO Adding welcome page: class path resource [static/index.html]
2025-11-16 19:53:20,279 INFO Exposing 1 endpoint(s) beneath base path '/actuator'
2025-11-16 19:53:20,353 WARN You are asking Spring Security to ignore Ant [pattern='/**']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.
2025-11-16 19:53:20,354 INFO Will not secure Ant [pattern='/**']
2025-11-16 19:53:20,354 WARN You are asking Spring Security to ignore Mvc [pattern='/prometheus']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.
2025-11-16 19:53:20,354 INFO Will not secure Mvc [pattern='/prometheus']
2025-11-16 19:53:20,354 WARN You are asking Spring Security to ignore Mvc [pattern='/prometheus/namespaceId/{namespaceId}']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.
2025-11-16 19:53:20,354 INFO Will not secure Mvc [pattern='/prometheus/namespaceId/{namespaceId}']
2025-11-16 19:53:20,354 WARN You are asking Spring Security to ignore Mvc [pattern='/prometheus/namespaceId/{namespaceId}/service/{service}']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.
2025-11-16 19:53:20,354 INFO Will not secure Mvc [pattern='/prometheus/namespaceId/{namespaceId}/service/{service}']
2025-11-16 19:53:20,477 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'
2025-11-16 19:53:20,493 INFO No TaskScheduler/ScheduledExecutorService bean found for scheduled processing
2025-11-16 19:53:20,558 INFO Nacos started successfully in stand alone mode. use external storage
加了- name: NACOS_CORE_REMOTE_SERVER_PORT
value: "9848"为什么不显示