2

I am trying to make calls to EOS nodeos server inside a docker container from the host machine.

Although the port 7777 is exposed:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
e447cb3d2db5        eosio/eos           "/bin/bash"              3 days ago          Up 3 days           0.0.0.0:7777->7777/tcp   server

When making the curl request, I get a 400 Bad Request error.

$ curl -vv -X POST http://127.0.0.1:7777/v1/chain/get_info
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 7777 (#0)
> POST /v1/chain/get_info HTTP/1.1
> Host: 127.0.0.1:7777
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 400 Bad Request

the docker network is:

$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
d3d275c83226        bridge              bridge              local
9f6a5439c22c        eosnetwork          bridge              local
db156b84ea13        host                host                local
83e9116a4419        none                null                local

Any idea why it is happening and how to fix it?

UPDATE

curl to the ip of the container works:

$ curl  -X POST http://172.18.0.2:7777/v1/chain/get_info
{"server_version":"08819aae","chain_id":"aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906","head_block_num":8085665,"last_irreversible_block_num":8085335,"last_irreversible_block_id":"007b5f5749c6dd4f268adc7e93597d0d6e0f8a6e2f04ec3f7b6c45e292ecac0f","head_block_id":"007b60a1e043ecee30589a74540ef241a287f16a0610b6d2fa33421adefe366a","head_block_time":"2018-07-27T19:08:14.500","head_block_producer":"eos42freedom","virtual_block_cpu_limit":200000000,"virtual_block_net_limit":1048576000,"block_cpu_limit":200000,"block_net_limit":1048576,"server_version_string":"v1.2.5"}

but I need it to work on from 127.0.0.1. Anyway to achieve that?

2

After two days of trials and errors, I finally made it work.

To access the nodeos from another machine we need to do two things:

  1. start the docker where the nodeos is running with "docker run --net=host" option
  2. start the nodeos with "--http-validate-host=false" option

I hope it helps someone in the future!

| improve this answer | |
0

This is the tutorial for the docker image: https://developers.eos.io/eosio-nodeos/docs/docker-quickstart

According to the docker documentation (https://docs.docker.com/config/containers/container-networking/), you need to add published port flag like -p 8888:8888 to your docker command. This will map the TCP port 8888 of the container to the TCP port 8888 of the Docker host.

--http-validate-host=false is needed as well in your nodeos config.ini.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.