Deploy Nacos 3.0 via Docker and Webman: Service Registration, Discovery & Config
This guide explains Nacos 3.0 architecture, shows how to quickly deploy it with Docker, configure JWT authentication, verify service startup, perform service registration and discovery, publish and retrieve configurations, and integrate Nacos with the Webman PHP framework using the webman‑nacos plugin.
Nacos 3.0 Overview
Nacos provides service discovery, configuration management, and service governance for microservice/SOA architectures, acting as both a configuration center and a service registry. Version 3.0 focuses on AI‑native scenarios, improves security with default authentication, supports zero‑trust data sources, and offers multi‑language support.
Docker Quick Deployment
Run the official Nacos Docker image. The first execution pulls the image; you can pre‑pull it to reduce wait time.
docker run --name nacos-standalone-derby \
-e MODE=standalone \
-e NACOS_AUTH_TOKEN=TXJHZGg5cDNFb0l2MmROeDJaRm1Da3pkSzFKQmJzSm8= \
-e NACOS_AUTH_IDENTITY_KEY=tinywan \
-e NACOS_AUTH_IDENTITY_VALUE=123456 \
-p 8080:8080 \
-p 8848:8848 \
-p 9848:9848 \
-d nacos/nacos-server:latestNote: NACOS_AUTH_TOKEN is the secret key for generating JWT tokens; use a string longer than 32 characters and Base64‑encode it.
base64_encode('MrGdh9p3EoIv2dNx2ZFmCkzdK1JBbsJo');Verify Service Startup
Check the container logs: docker logs -f $container_id If the logs contain the expected startup messages, the service is running.
Service Registration
curl -X POST 'http://127.0.0.1:8848/nacos/v3/client/ns/instance?serviceName=quickstart.test.service&ip=127.0.0.1&port=8080'Successful registration returns:
{"code":0,"message":"success","data":"ok"}Service Discovery
curl -X GET 'http://127.0.0.1:8848/nacos/v3/client/ns/instance/list?serviceName=quickstart.test.service' {"code":0,"message":"success","data":"ok"}Publish Configuration
Obtain an access token:
curl -X POST 'http://127.0.0.1:8848/nacos/v3/auth/user/login' -d 'username=nacos' -d 'password=nacos' {"accessToken":"eyJhbGciOiJIUzI1NiJ9...","tokenTtl":18000,"globalAdmin":true,"username":"nacos"}Use the token to create a configuration:
curl -X POST 'http://127.0.0.1:8848/nacos/v3/admin/cs/config?dataId=quickstart.test.config&groupName=test&content=HelloTinywan' \
-H "accessToken:eyJhbGciOiJIUzI1NiJ9..." {"code":0,"message":"success","data":true}Retrieve Configuration
curl -X GET 'http://127.0.0.1:8848/nacos/v3/client/cs/config?dataId=quickstart.test.config&groupName=test' {"code":0,"message":"success","data":{"content":"HelloTinywan",...}}Webman Integration
Webman is a high‑performance PHP framework. The following steps show how to use Nacos with Webman.
Install Webman
composer create-project workerman/webman:~2.0 webman2.xInstall webman‑nacos Plugin
composer require workbunny/webman-nacosService Registration via Webman
$client = \Workbunny\WebmanNacos\Client::channel();
$response = $client->instance->register('127.0.0.1', 8848, 'webman.test.service', ['groupName' => 'DEFAULT_GROUP']);
var_dump($response);Service Discovery via Webman
$client = \Workbunny\WebmanNacos\Client::channel();
$response = $client->instance->list('webman.test.service', []);
var_dump($response);Publish Configuration via Webman
$client = \Workbunny\WebmanNacos\Client::channel();
$response = $client->config->publish('webman.config.app.php', 'DEFAULT_GROUP', file_get_contents(config_path().'/app.php'));
print_r($response);Config Listener
The plugin starts a config-listener process that watches the config_listeners array in plugin/workbunny/webman-nacos/app.php. Add entries such as 'webman.config.app.php' to automatically sync remote configurations to local files.
'config_listeners' => [
[
'webman.config.app.php',
'DEFAULT_GROUP',
'',
config_path().'/app.php',
],
// additional listeners can be added here
],After editing the listener configuration, start Webman; changes in Nacos will be reflected in the local configuration files automatically.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
