Docker Community Forums

Share and learn in the Docker community.

Docker compose doesn't let my images connect with each other


(Fasmat) #1

I have a docker compose file that starts two images:

version: '3'
    image: trufflesuite/ganache-cli:latest
      - "8545:8545"

    image: -- my custom image --
      - ganache

app contains a small script that connects to ganache-cli via port 8545 and fails to do so if I run this docker composition.

If I run ganache-cli on my machine and run my script it works without an issue. I’m aware that I cannot forward the port to localhost on mac but can I at least somehow connect the docker images with each other so that my custom image can access ganache-cli via localhost:8545 ?

Thanks in advance!

(Martin Terp) #2

Hi :slight_smile:

Try from your app container, and connect to the ganache like this: ganache:8545 ( since its the service name )

(Fasmat) #3

Hi terpz!

Thanks for your response. Using curl from my app container I can indeed access the ganache container with ganache:8545. It also revealed to me that the full name of the container is actually: docker_ganache_1.docker_default:8545

Using that from my application in the app container did let me access the ganache container. Accessing it from the host did not work though, neither with ganache:845 nor with the full domain name. Is that even possible?

(Martin Terp) #4

Hi again

from the host it will be: “localhost:8545”

(Fasmat) #5

Well guess I’m just stupid :smiley:

I was using docker-machine the whole time instead of, apparently that’s not the recommended way to use docker on mac any more. Purged everything reinstalled, works without issues now ^^

Thanks for your help though!

(Martin Terp) #6

oh! yea its more native now :slight_smile: