Docker deploys Nacos2 to obtain the pit of failure of dynamic configuration

The failure of Nacos2 to obtain dynamic configuration is recorded here
nacos: 2.0+
dependencies are also introduced, the configuration is configured correctly, and the annotations that should be written are also written, but an error is reported
[Nacos Config] config[dataId=xxx.yml, group=DEFAULT_GROUP ] is empty
insert image description here
reason:
nacos official website explanation

insert image description here
insert image description here

Just add two additional port mappings to the nacos container

Attach the docker stand-alone deployment nacos command:

Pull the nacos image

docker pull nacos/nacos-server:v2.2.3

Run the nacos container

docker run -d --name nacos \
-p 8848:8848 -p 9848:9848 -p 9849:9849 \
-e PREFER_HOST_MODE=ip \
-e MODE=standalone \
-e NACOS_AUTH_ENABLE=true \
-e NACOS_AUTH_TOKEN=xxx \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST=xxx \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_DB_NAME=nacos\
-e MYSQL_SERVICE_USER=xxx\
-e MYSQL_SERVICE_PASSWORD=xxx\
-v xxx:/home/nacos/logs \
-v xxx:/home/nacos/conf \
--restart=always \
nacos/nacos-server:v2.2.3

Replace the above xxx with your own
-d: run in the background
-p: set port mapping
-e: set environment variables
For details on the role of variables, see the official website
nacos official website docker deployment
-v: set file mount

The docker persistence will not be repeated here, Baidu--

Guess you like

Origin blog.csdn.net/weixin_43636205/article/details/131944907