How to prevent Docker from looking up host names via external DNS?

Say you have the following docker-compose file:

version: '3.5'

services:
  web:
    image: nginx
    expose:
      - 80

  # Imaginary service that requests http://web/
  curl:
    image: curlimages/curl
    command: curl -i http://web/
    

If web is down, accessing http://web/ will trigger an external DNS lookup. In my case, this caused several hundred thousand requests per hour to our DNS server.

How can I prevent Docker from externally looking up host names when a container is down?