已开发带查询与交易的Hyperledger Composer应用,能否用Fauxton对接暴露的Docker容器?
Absolutely feasible! Let me walk you through how to make this work—Hyperledger Composer integrates smoothly with CouchDB, which comes with Fauxton (its built-in web admin interface) out of the box. You can absolutely connect to your Composer-backed CouchDB instance via Fauxton to query and inspect transaction data. Here's a step-by-step breakdown:
1. Switch your Composer app to use CouchDB (not LevelDB)
By default, Hyperledger Composer might use LevelDB, which doesn’t work with Fauxton. You’ll need to update your connection profile to use CouchDB instead:
- Open your connection profile JSON file (usually located in
./connection-profiles/) - Locate the peer configuration section, then modify the database settings to point to CouchDB:
"peers": { "peer0.org1.example.com": { "url": "grpc://localhost:7051", "eventUrl": "grpc://localhost:7053", "database": { "type": "couchdb", "url": "http://admin:admin@localhost:5984", "database": "composer_peer0org1examplecom" } } } - Double-check that the CouchDB URL matches the credentials and port you’ll expose later.
2. Expose the CouchDB container port
Your Hyperledger Fabric/CouchDB Docker container probably doesn’t have port 5984 (CouchDB’s default port) mapped to your host machine yet. Update your docker-compose.yml file to add the port mapping:
- Find the CouchDB service entry (often named
couchdbor bundled with a peer likepeer0.org1.example.com) - Add the port mapping under the
portssection:services: couchdb: image: hyperledger/fabric-couchdb:latest ports: - "5984:5984" # Map host port 5984 to container port 5984 environment: - COUCHDB_USER=admin - COUCHDB_PASSWORD=admin
3. Restart your Docker containers
Apply the changes by restarting your Fabric/Composer stack:
docker-compose down docker-compose up -d
Give it a minute or two for all services to fully spin up.
4. Access Fauxton and interact with your Composer data
- Open your browser and go to
http://localhost:5984/_utils - Log in using the credentials you set in
docker-compose.yml(e.g.,admin/admin) - You’ll see a list of databases—look for one named something like
composer_<your-business-network-namespace>_<your-business-network-name>(this is where Composer stores its world state and transaction history) - Click into the database to browse documents, run ad-hoc queries using CouchDB’s Mango syntax, or inspect transaction records directly.
Key Notes to Keep in Mind
- Security Warning: Never expose CouchDB directly to the internet in a production environment. Use strong authentication, restrict access with firewalls, and consider a TLS-enabled reverse proxy if remote access is needed.
- Avoid Direct Edits: Composer manages the ledger’s consistency—don’t modify documents directly in Fauxton unless you’re 100% sure what you’re doing, as this could break the ledger’s integrity.
- Database Naming: If you’re unsure which database corresponds to your business network, check Composer’s logs for references to the CouchDB database URL.
内容的提问来源于stack exchange,提问作者ghindle

