Docker Community Forums

Share and learn in the Docker community.

Can't connect to service from another service by its name

Docker version 18.03.0-ce, build 0520e24

Hi everyone, I’m having trouble accessing one service from inside another by its name.
Here is the docker-compose.yml:

version: “3.6”

image: restimage
replicas: 1
- “8081:8081”

image: scrimage
- rest
replicas: 1

scraper has the code that is trying to reach rest:8081 and is failing.
Before it was solved using links but they got deprecated.
I tried creating custom network which didn’t help.
Thank you!

Addition: I ranping rest inside scraper and it returns

ping: unknown host rest

but then it pings some internal IP address.

Does the restimage container start as it should?

And, btw, convention recommends to not name your images something with image in it… :wink:

It does, and I can access it from host using docker machine ip.
One interesting thing I’ve noticed that when I do
docker network inspect scraper_default
in the attached containers it has names

“Name”: “scraper_rest.1.pmr5h9igwa7mut46wam”
“Name”: “scraper_scraper.1.kxgivjn6bq2dt8akdw6”

for containers respectively.
Aren’t they supposed to be “rest” and “scraper”?
Thank you for your response!