'docker-compose up / docker-compose build giving error: Service 'greeter_client' depends on service ' greeter server' which is undefined [closed]

Downloaded the following: https://github.com/grpc/grpc/tree/master/examples/python/helloworld

Created Client.Dockerfile and Server.Dockerfile (and requirements.txt file) built and ran those images, all seemed to work

Tried creating docker-compose.yml file and running docker-compose up but got the error: "Service 'greeter_client' depends on service ' greeter server' which is undefined."

download that wait-for-it.sh script from https://github.com/vishnubob/wait-for-it. used chmod to ensure executable and added depend with that script to my docker-compose.yml (see code below)

Still getting same error: "Service 'greeter_client' depends on service ' greeter server' which is undefined."

docker-compose.yml:

version: '3' 
services: 
  greeter_service: 
    build: 
      context: . 
      dockerfile: Server.Dockerfile 
    ports:  
      - "50051:50051" 
  greeter_client: 
    build: 
      context: . 
      dockerfile: Client.Dockerfile 
    depends_on: 
      - "greeter_server" 
    command: ["./wait-for-it.sh", "greeter_server:50051", "--
", "python3", "greeter_client.py"] 


Solution 1:[1]

You've named the service greeter_service rather than greeter_server.

Change it like this

version: '3' 
services: 
  greeter_server: 
    build: 
      context: . 
      dockerfile: Server.Dockerfile 
    ports:  
      - "50051:50051" 
  greeter_client: 
    build: 
      context: . 
      dockerfile: Client.Dockerfile 
    depends_on: 
      - "greeter_server" 
    command: ["./wait-for-it.sh", "greeter_server:50051", "--
", "python3", "greeter_client.py"] 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hans Kilian