You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在Hyperledger Composer-Playground容器内启动REST Server及问题咨询

Great question! Let's tackle this from three key angles: whether you can run the Composer REST Server inside the playground container, fixing that Python error you hit, and how to interact with your business network once it's set up.

Can You Run the Composer REST Server Inside the hyperledger/composer-playground Container?

Absolutely — but you'll need to address missing dependencies first (like the Python issue you encountered) since the base playground container doesn't come with all tools pre-installed. Let's walk through fixing that error first.

Fixing the "Can't find Python executable 'python'" Error

This error pops up because some npm packages (including parts of composer-rest-server) expect a python executable in the PATH, but the playground container doesn't have Python installed by default. Here's how to fix it:

  1. First, access the running container's shell:
    Run this command on your host machine (replace <container-id/name> with your playground container's ID or name — you can get this via docker ps):

    docker exec -it <container-id/name> /bin/bash
    
  2. Install Python and link it to the python alias:
    The container is based on Ubuntu, so we can use apt to install Python 3 and set it as the default python executable:

    apt-get update && apt-get install -y python-is-python3
    

    This package creates a symlink from python to python3, which satisfies the npm package's requirement.

  3. Install the Composer REST Server:
    Now you can install the server globally without errors:

    npm install -g composer-rest-server
    
Interacting with the Business Network Inside the Container

Once the REST Server is installed, you have two main ways to interact with your business network:

1. Run the REST Server inside the container (with port mapping)

  • If you haven't started the container yet: Launch it with port 3000 (the default REST Server port) mapped to your host:

    docker run -p 8080:8080 -p 3000:3000 hyperledger/composer-playground
    

    (Port 8080 is for the playground UI, 3000 is for the REST Server.)

  • If the container is already running: After installing the REST Server inside, start it with:

    composer-rest-server -c admin@<your-business-network-name> -n never -w true
    
    • -c: Specifies the connection profile for your business network (use the same name you used when deploying the network in the playground).
    • -n never: Disables TLS (safe for testing environments).
    • -w true: Allows anonymous access to the REST API (again, for testing — restrict this in production).

    You can now access the REST API from your host machine at http://localhost:3000, and use the Swagger UI to test endpoints or connect your application to it.

2. Persist your setup (avoid re-installing on container restart)

Since Docker containers are ephemeral, any changes (like installing Python or the REST Server) will be lost when the container stops. To avoid redoing this every time, create a custom Docker image:

  1. Create a Dockerfile with:

    FROM hyperledger/composer-playground
    RUN apt-get update && apt-get install -y python-is-python3
    RUN npm install -g composer-rest-server
    
  2. Build the image:

    docker build -t my-composer-playground .
    
  3. Run your custom image with port mapping:

    docker run -p 8080:8080 -p 3000:3000 my-composer-playground
    

Now every time you start the container, the REST Server and Python will already be installed and ready to use.


内容的提问来源于stack exchange,提问作者Bharath

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:15:25