1

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

Sam_2207
  • 2,759
  • 2
  • 9
  • 15
  • 1
    Is `rest-api` the name of your service or container? Are the two containers on the same user defined network? Please include all the steps that can be used to reproduce your issue. [mcve] – BMitch Mar 30 '18 at 10:58
  • 1
    here rest-api is a service. First I ran $ docker-compose -f sawtooth-default.yaml up – Sam_2207 Mar 30 '18 at 18:31
  • here rest-api is a service. First I ran below command to download the docker images $ docker-compose -f sawtooth-default.yaml up The logged into the container using below command $ docker exec -it sawtooth-shell-default bash then inside the root@75b380886502:/# I am running $ curl http://rest-api:8080/blocks to confirm that our validator is up and running, and reachable from the client container. – Sam_2207 Mar 30 '18 at 18:38
  • If we try to run that command, it would say sawtooth-default.yaml is not found. Since we are not in your machine, you'll need to provide all the details to replicate your problem on another machine. [mcve] (note the "complete" part of that guide) – BMitch Mar 30 '18 at 18:42
  • Thanks BMitch, I think complete replication will be time taking for you as this process involves installing docker and other things, I am getting this error on last stage of installing the sawtooth hyperledger where we are checking if Validator is up and running fine. – Sam_2207 Mar 30 '18 at 19:13
  • Can you post the `rest` portion of the yaml as well as what you see when you do `docker ps -a` – Frank C. Mar 31 '18 at 11:23
  • 1
    Thanks Frank, You open my mind, I just checked the yaml file and saw that rest-api is bind to 8008 port and not to 8080 which i was using. – Sam_2207 Mar 31 '18 at 12:58

2 Answers2

0

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.

grkvlt
  • 2,577
  • 1
  • 21
  • 38
0

Just use this command, it will work

 curl http://rest-api-0:8008/blocks

this is because the rest-api-0 is mentioned in the docker file.