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?
Something you could try is a docker-compose with your app and a build-in geth docker image.
version: '3' services: geth: image: kunstmaan/ethereum-geth-testnet ports: - "8545:8545" - "30303:30303" stdin_open: true tty: true your_app: build: ./ ports: - "8080:8080" (...)
Build the image
$ docker-compose -f docker-compose.yml build
$ docker-compose -f docker-compose.yml up
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:
- Make sure you have --rpc and --rpccorsdomain flags when starting Geth
- 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"));