Is there a way to prevent a docker container from communicating to another specific container in a docker-compose file?

I don’t want to pass the -icc flag in a network driver options, because I want all of them to talk to each other. But for some reason, putting them in separate networks doesn’t resolve the issue. Is there anything else I can do? Perhaps with ipTables?