Go-ethereum: Can't use rpc http api when using docker image

Created on 14 Jun 2017  路  7Comments  路  Source: ethereum/go-ethereum

Hello,

I'm trying to setup a ethereum (with docker) on personal dedicated server, then use it with personal computer installed Ethereum Wallet/Mist. But RPC api seems not available. Thank's.

System information

uname -a
Linux xyz 3.14.32-xxxx-grs-ipv6-64 #7 SMP Wed Jan 27 18:05:09 CET 2016 x86_64 GNU/Linux
docker run -it -p 8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "127.0.0.1"
[...]
INFO [06-14|19:53:39] Starting peer-to-peer node               instance=Geth/v1.6.6-unstable/linux-amd64/go1.7.3
[...]
INFO [06-14|19:50:38] HTTP endpoint opened: http://127.0.0.1:8545 
INFO [06-14|19:50:38] IPC endpoint opened: /root/.ethereum/geth.ipc 

Expected behaviour

RPC HTTP interface available on http://127.0.0.1:8545.

Actual behaviour

No RPC HTTP interface on http://127.0.0.1:8545:

curl http://127.0.0.1:8545
curl: (56) Recv failure: Connection reset by peer

Steps to reproduce the behaviour

Run docker run -it -p 8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "127.0.0.1" then run curl http://127.0.0.1:8545.

Most helpful comment

@buxx setting --rpcaddr to 127.0.0.1 means that geth is listening on the local interface inside the Docker container, which is distinctly different from the local interface on your machine.

What you need to do is run docker with -p 127.0.0.1:8545:8545 to map your local 8545 port to the docker container's public 8545 port, and then set --rpcaddr to 0.0.0.0 so that geth listens on the container's public interface.

So:

$ docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "0.0.0.0"

All 7 comments

@buxx setting --rpcaddr to 127.0.0.1 means that geth is listening on the local interface inside the Docker container, which is distinctly different from the local interface on your machine.

What you need to do is run docker with -p 127.0.0.1:8545:8545 to map your local 8545 port to the docker container's public 8545 port, and then set --rpcaddr to 0.0.0.0 so that geth listens on the container's public interface.

So:

$ docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "0.0.0.0"

Hello,

I'm totally sorry you're entirely right !

Bux.

I greatly appreciate this thread as I was having the same issue, but I cannot get it to work! Running geth on the machine itself, I can connect just fine. If it's running inside Docker, though, connections are refused (and, in fact, I don't even see the "HTTP endpoint opened" message in the logs.

Any idea what might be going on?

@EvilJordan are you running that exact command that I posted?

@lmars I'm running this:
docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go:alpine --syncmode "light" --cache=512 --rpc --rpcaddr "0.0.0.0"

I've also tried with:
docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --syncmode "light" --cache=512 --rpc --rpcaddr "0.0.0.0"
and
docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "0.0.0.0"

@EvilJordan ok, and then what? Are you getting an error somewhere?

@lmars No, no errors at all. I think it has something to do with the container<->docker relationship and port bindings. I'm still digging away!

Was this page helpful?
0 / 5 - 0 ratings