I run private geth testnet and my program is on docker. Everytime I try to call api I get: no JSON RCP response. Must I run geth on docker too?

  • Your program doesnt have an access to host OS. – Зелёный Jan 30 '18 at 7:14

Something you could try is a docker-compose with your app and a build-in geth docker image.

For example


version: '3'
    image: kunstmaan/ethereum-geth-testnet
      - "8545:8545"
      - "30303:30303"
    stdin_open: true
    tty: true

    build: ./
      - "8080:8080"

Build the image

$ docker-compose -f docker-compose.yml build

Run it

$ docker-compose -f docker-compose.yml up
  • my docker-compose.yml: – Agniezhk Jan 30 '18 at 10:23
  • are you trying to connect to http://localhost:8545 ? – Greg Jeanmart Jan 30 '18 at 10:38
  • yes, localhost:8545 – Agniezhk Jan 30 '18 at 11:44
  • in Dockerfile, do you expose 8545: EXPOSE 8545 – Greg Jeanmart Jan 30 '18 at 13:43

I ran into the same problem. I had a web server running in a Docker Container and an Ethereum node (for testnet) running on my machine. It seemed the app in Docker wont be able to connect to the node outside of it. Here is how I solved that issue without having to run Geth node inside my container:

  1. Make sure you have --rpc and --rpccorsdomain flags when starting Geth
  2. In your Application running inside Docker, make sure to point your web3 provider to your machine correctly https://docs.docker.com/docker-for-mac/networking/ for my machine i had to use: "docker.for.mac.localhost".

web3 = new Web3(new Web3.providers.HttpProvider("http://docker.for.mac.localhost:8545"));

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.