在测试从Docker容器到验证器的连接性时面对问题.curl http:// rest-api:8008/块



背景:设置Hyperledger-锯齿的环境。

运行命令curl http://rest-api:8008/块从客户端容器中测试验证器的连接性。获取错误:无法解析主机REST-API

如果您使用的是Sawtooth Master Branch的锯齿 - 局部安装。YAML,则REST API服务在rest-api容器上的端口8008上公开,也转发到端口8008在主机上:

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

因此,应以http://rest-api:8008/块或主机作为http://127.0.0.1:8008/blocks通过Web浏览器或curl从另一个Docker容器访问该服务。如果您仍然有问题,请尝试更改entrypoint命令将--bind 0.0.0.0:8008用作最后一个参数。

只需使用此命令,它将起作用

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

这是因为rest-api-0在Docker文件中提到。