Docker Desktop deploys nacos (stand-alone mode)
1. Pull the image
cmd run:
docker pull nacos/nacos-server
2. Create a data volume
In the Volumes column of the docker Desktop menu, click create+ in the upper right corner to create a data volume (here named nacos-standalone)
3. Start the container
cmd run:
docker run --name nacos-standalone -p 8848:8848 -p 9848:9848 -v nacos-standalone:/home/nacos/conf/ -e MODE=standalone -d nacos/nacos-server
After the creation is successful, the container ID is displayed, and the results are as follows:
4. View the results
4.1. View data volume
Displayed in the Volumes column of the docker Desktop menu:
At this time, STATUS shows in use, click to view:
you can see that the nacos container has mounted the current data volume nacos-standalone, view DATA:
here displays the internal directory of the container after the mount is successful.
Use the idea tool to view the internal directory of the container, the results are as follows:
4.2. View container
Displayed in the Containers column of the docker Desktop menu:
shows that the container has been started.
Click to view the log, then click open in browser to access directly (jump to localhost:8848)
url input http://localhost:8848/nacos to view the result
5. External Persistence
Use an external data source for persistence instead of using an embedded data source. (Here, take Ruoyi framework configuration nacos as an example)
5.1. Create database
Here use the sql script (ry_config_xxxxx.sql) provided by Ruoyi to create the database.
5.2. Create container
Here you need to specify MySQL related parameters as follows: (official parameter list: https://github.com/nacos-group/nacos-docker)
cmd execution:
docker run --name nacos-ruoyi -p 8848:8848 -p 9848:9848 -v nacos-ruoyi:/home/nacos/conf/ -e MODE=standalone -e SPRING_DATASOURCE_PLATFORM=mysql -e MYSQL_SERVICE_HOST=localhost -e MYSQL_SERVICE_DB_NAME=ry-config -e MYSQL_SERVICE_USER=root -e MYSQL_SERVICE_PASSWORD=password -e MYSQL_DATABASE_NUM=1 -d nacos/nacos-server
5.3. Modify configuration
Enter the url \wsl$\docker-desktop-data\data\docker\volumes\ to view the data volume
Now to modify the content of the data volume, tutorial: https://blog.csdn.net/JackieDYH/article/details/123194190?
to be continued…