I can't seem to be able to create a web3 (http) provider pointing to a parity node, running from a docker container. I create a repo which should reproduce the problem.

After running docker-compose up the parity starts, but the app fails:

Creating network "dockerweb3_net" with driver "bridge"
Attaching to qa_parity, qa_app
qa_parity | 2018-09-27 07:50:52 UTC Starting Parity-Ethereum/v2.0.6-stable-7658d22-20180921/x86_64-linux-gnu/rustc1.29.0
qa_parity | 2018-09-27 07:50:52 UTC Keys path /root/.local/share/io.parity.ethereum//keys/test
qa_parity | 2018-09-27 07:50:52 UTC DB path /root/.local/share/io.parity.ethereum//chains/test/db/ae90623718e47d66
qa_parity | 2018-09-27 07:50:52 UTC State DB configuration: fast
qa_parity | 2018-09-27 07:50:52 UTC Operating mode: active
qa_parity | 2018-09-27 07:50:52 UTC Configured for Ropsten using Ethash engine

qa_app    | /app/app.js:6
qa_app    |   throw "Can't connect to Ethereum node: qa_parity:8545";

Now if I get a shell to the failing container on the same docker network I can reach parity:

docker run --net dockerweb3_net -it dockerweb3_app /bin/bash

curl --data '{"method":"web3_clientVersion","params":[],"id":1,"jsonrpc":"2.0"}' \
-H "Content-Type: application/json" \
-X POST qa_parity:8545

> {"jsonrpc":"2.0","result":"Parity-Ethereum//v2.0.6-stable-7658d22-20180921/x86_64-linux-gnu/rustc1.29.0","id":1}

Since 8545 is exposed, the parity is also reachable from the host (http://localhost:8545), so the problem must come from when creating the provider.


Seems like web3 simply requires a full path and not just the IP address. Connecting to the container and passing the url works:

env URL_PARITY="http://qa_parity:8545" node app.js
| 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.