Running a container in another container network mode

So I had a docker image which had database host hardcoded to localhost, So in network_mode in docker compose file we could use container’s name to run in same network so that it is accessible through localhost.

 network_mode: "container:thinger"