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
docker-compose.yml
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
Run it
$ 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"));