Kill postgres in docker container which has multiple services (apps)

So I have a multi-faceted dockerised project, in which one container contains the core of the program and also a database. So it’s not possible for me to kill that container.

The reason I need to kill this container is because I am doing testing on our graphQL end point to improve retry logic (because some GQL queries fail due to infrastructure problems).

I’ve tried removing the core-db service from my docker-compose.yaml file, but that doesn’t stop postgres from running it. Weirdly so, it runs postgres still.

And the port is exposed when I do:

docker ps | grep 5432
(5432 being the db’s port), it is exposed.

Any ideas on how I can achieve this?

Is there a way to somehow block postgres from responding to the core of my program? So that I can intentionally make GraphQL fail to respond (to simulate what I’m trying to achieve above).

Source: StackOverflow