How to make a Docker container talk to geth on local host

Question:

I have a simple python script using web3 Dockerized and I’m trying to connect to geth.ipc on local host and I can’t seem to connect to it. Is there a way to do it?

Python:

from web3 import Web3

web3 = Web3(Web3.IPCProvider("/Ethereum/geth.ipc"))
print(f'IPC connected: {web3.isConnected()}')  # want to return True

And I’m mounting my $HOME/Library/Ethereum/geth.ipc -> /Ethereum/geth.ipc

Asked By: Eric

||

Answers:

If you mount the folder containing the IPC file rather than mounting the file directly it will work.

Answered By: Daniel