Files
nacos-server-kingbase/Dockerfile
2025-09-29 11:08:22 +08:00

45 lines
1.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM jdk8u112:v1
MAINTAINER zhangfucai
ENV TZ "Asia/Shanghai"
RUN echo "set fileencodings=utf-8,gbk,gb2312,gb18030,cp936,latin1 \n set fenc=utf-8 \n set tenc=utf-8 \n set enc=utf-8 \n" |tee ~/.vimrc
# 定义Nacos版本可根据需要修改
ENV NACOS_VERSION=2.3.2
ENV MODE=standalone
ENV BASE_DIR=/home/nacos
ENV PREFER_HOST_MODE=hostname
COPY ./distribution/target/nacos-server-${NACOS_VERSION}.tar.gz /home/
# 创建目录并复制本地编译的Nacos包
RUN cd /home && \
tar -zxvf nacos-server-${NACOS_VERSION}.tar.gz && \
rm -rf /home/nacos-server-${NACOS_VERSION}.tar.gz && \
rm -rf /home/nacos/bin/*
WORKDIR ${BASE_DIR}
# 添加启动脚本
ADD ./distribution/bin/docker-startup.sh ${BASE_DIR}/bin/
RUN chmod +x ${BASE_DIR}/bin/docker-startup.sh
# 暴露端口
EXPOSE 8848 9848 9849
# 设置数据和日志目录为挂载点
VOLUME ["${BASE_DIR}/conf/application.properties","${BASE_DIR}/logs", "${BASE_DIR}/data"]
# 启动命令(支持动态参数)
ENTRYPOINT ["sh", "-c", "${BASE_DIR}/bin/docker-startup.sh"]
# docker build -t nacos-server-kingbase:2.3.2 .
# 启动命令
# docker run -d --restart always --name nacos-server \
# -p 8848:8848 -p 9848:9848 -p 9849:9849 \
# -e MODE=standalone \
# -v /docker-data/nacos/conf/application.properties:/home/nacos/conf/application.properties \
# nacos-server-kingbase:2.3.2