0

I'm trying to run a bare bones version of Hyperledger Sawtooth using Docker CE on a Mac. The docker-compose.yaml has containers running the base images from Sawtooth.

I'm unable to access the Sawtooth REST API from the host machine even though there are ports published for it when I run docker ps. The docker-compose file has worked on other Macs running Docker CE so I'm suspecting it may be a configuration or setup issue.

The contents of the docker-compose.yaml are below:

version: '2.1'

services:
  settings-tp:
    image: 'hyperledger/sawtooth-settings-tp:1.1.3'
    container_name: sawtooth-settings-tp
    depends_on:
      - validator
    entrypoint: settings-tp --connect tcp://validator:4004

  identity-tp:
    image: 'hyperledger/sawtooth-identity-tp:1.1.3'
    container_name: sawtooth-identity-tp
    depends_on:
    - validator
    entrypoint: identity-tp -vv --connect tcp://validator:4004

  rest-api:
    image: 'hyperledger/sawtooth-rest-api:1.1.3'
    container_name: sawtooth-rest-api
    ports:
      - '8008:8008'
    depends_on:
      - validator
    entrypoint: sawtooth-rest-api --connect tcp://validator:4004 --bind rest-api:8008

  validator:
    image: 'hyperledger/sawtooth-validator:1.1.3'
    container_name: sawtooth-validator
    ports:
      - '4004:4004'
    command: |
      bash -c "
        if [ ! -f /etc/sawtooth/keys/validator.priv ]; then
          sawadm keygen
          sawtooth keygen my_key
          sawset genesis -k /root/.sawtooth/keys/my_key.priv
          sawset proposal create \
                    -k /root/.sawtooth/keys/my_key.priv \
                    sawtooth.consensus.algorithm.name=Devmode \
                    sawtooth.consensus.algorithm.version=0.1 \
                    -o config.batch && \
          sawadm genesis config-genesis.batch config.batch
        fi;
        sawtooth-validator -vvv \
          --endpoint tcp://validator:8800 \
          --bind component:tcp://eth0:4004 \
          --bind network:tcp://eth0:8800 \
          --bind consensus:tcp://eth0:5050 \
      "

  devmode-engine:
    image: 'hyperledger/sawtooth-devmode-engine-rust:1.1.3'
    container_name: sawtooth-devmode-engine-rust-default
    depends_on:
    - validator
    entrypoint: devmode-engine-rust -C tcp://validator:5050
bl4
  • 1
  • 1
  • 1
    what do you mean "you are not able"? Can you post the error? Also if you login the "rest-api" container (e.g. docker exec -ti rest-api /bin/sh) can you access the end-point from there? Also there are references to a container "eth0" but I don't see its declaration. Maybe something is missing? – Mihai Apr 02 '19 at 04:24
  • I don't get any errors if I try to access the container; the curl request is stuck waiting and nothing happens during that time. However, if I login to the 'rest-api' container or other ones, I'm able to access the endpoints. As for 'eth0', the docker-compose file from a sample Sawtooth repo also follows the same pattern of not having a declared container and still referring to it, so I think it should be okay? (https://github.com/hyperledger/sawtooth-supply-chain/blob/master/docker-compose.yaml) – bl4 Apr 05 '19 at 18:23
  • What is the URL you are accessing. It should be something like: `curl http://localhost:8008/blocks` outside Docker and for your configuration, `curl http://rest-api:8008/blocks` inside a Docker container. – Dan Anderson Apr 05 '19 at 21:12

1 Answers1

0

If you cannot access the port from the host, the container must not be running correctly. Look for error messages for that container when starting docker-compose

What does docker ps -a show?

Can you connect to the port? Try something like telnet localhost 8008

Dan Anderson
  • 2,265
  • 1
  • 9
  • 20
  • I don't see any errors in the containers or any of them exiting out; I've successfully ran them on different machines and the logs look similar. I'm able to connect the rest-api container from another container if that counts for anything. `docker ps -a` shows `hyperledger/sawtooth-rest-api:1.1.3 ... 4004/tcp, 0.0.0.0:8008->8008/tcp` for the rest-api container. I'm able to connect to the port using telnet. – bl4 Apr 05 '19 at 18:55