Ping Application on Local with Docker Compose

I am new to this docker area. i would be happy if you give me an opinion to make me search.
I want to ask a question about my project that i am working on. I have an api which is pinging a client. That’s why i created 2 docker files and 1 compose file. I got an error networking these two container and because one of them was closing. And That’s why other one can get needed things from closed.

Compose files:
FROM microsoft/dotnet
WORKDIR /app
COPY . .
CMD [ “dotnet”, “PingApp.Client.dll”, “http://localhost:5000/api/ping”]

and other one:
FROM microsoft/dotnet
WORKDIR /app
COPY . .
CMD [ “dotnet”, “PingApp.WebApi.dll”, “–server.urls”, “http://localhost:5000;http://*5001”]

and compose file:
version: ‘3.6’
services:
client:
container_name: client
build:
dockerfile: Dockerfile.dev
context: ./Client
networks:
- gateway
ports:
- 5000:5000
restart:
always
depends_on:
- server
server:
container_name: server
build:
dockerfile: Dockerfile.dev
context: ./Server
networks:
- gateway
ports:
- 5001:5000
restart:
always
networks:
gateway: {}