dockerhyperledgerhyperledger-sawtooth

Facing issues while testing connectivity from docker container to validator. curl http://rest-api:8008/blocks


Background: setting up the environment for Hyperledger- Sawtooth.

Running command curl http://rest-api:8008/blocks to test the connectivity of Validator from Client Container. getting error: could not resolve host rest-api


Solution

  • If you are using the sawtooth-local-installed.yaml from the Sawtooth master branch, then the REST API service is exposed on port 8008 on the rest-api container, and also forwarded to port 8008 on the host:

    rest-api:
      image: sawtooth-rest-api:latest
      container_name: sawtooth-rest-api-default
      expose:
        - 8008
      ports:
        - "8008:8008"
      depends_on:
        - validator
      entrypoint: sawtooth-rest-api --connect tcp://validator:4004 --bind rest-api:8008
    

    The service should therefore be accessible from another Docker container as http://rest-api:8008/blocks or from the host as http://127.0.0.1:8008/blocks via a web browser or curl. If you are still having problems, try changing the entrypoint command to use --bind 0.0.0.0:8008 as the last argument.