I currently have a setup with two docker containers. The first container, peerA, has a private ethereum network running a single node. The second container, web-app, has a web application that uses web3.js with the hope of interfacing with the private network in the first container.

Right now, I've managed to successfully get a connection from the first container to the second but have run into some issues with RPC.

The first container was run with the following commands:-

docker run -it --name peerA -v /opt/docker/ethereum:/root/.ethereum -p 30310:30310 -p 50000:50000 --network testnet docker-testnet --datadir ./peerA --networkid 4567 --port 50000 --rpc --rpcport 30310 --rpccorsdomain "*" --rpcapi "eth,web3,net,admin,miner,personal" --rpcvhosts "*" --ipcpath ./peerA

which opens an RPC endpoint at: http://peerA(or

Both containers are running on a docker network "testnet", so I obtained a connection in the web-app container with web3.js using the first containers name:-

const web3 = new Web3(new Web3.providers.HttpProvider("http://peerA:30310"));

This gives me a web3 instance which I successfully use to get access to a smart contract deployed on the private network. The issue now is, attempting to call functions on the contract object results in the following errors:-

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://peerA:30310/. (Reason: CORS request did not succeed)

followed by:

Unhandled promise rejection Error: "Invalid JSON RPC response: """

Which leads me to believe that there might be an issue with the --rpccorsdomain "*" flag.

I would greatly appreciate any assistance in resolving this error or even a better way of handling a web-app + private network docker setup.


try to append this to your command: --rpcaddr ""

| 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.