An override file normally adds to lists. So if the base file publishes 8080:80, an override can add more ports but has no plain way to take that one away. The YAML tags !reset and !override fix that.
!reset clears an attribute back to its default. !override replaces it completely, skipping the normal merge rules.
# compose.override.yaml: no published ports on this machine
services:
web:
ports: !reset []
# compose.prod.yaml: only this port, nothing from the base file
services:
web:
ports: !override
- "127.0.0.1:9090:80"
Without the tag, the production file would leave you with both 8080:80 and the new port, because ports are merged by appending. I’d guess that is the most common reason a port stays open after someone thought they had removed it.
You can also reset a single environment variable with FOO: !reset null. The value you write after !reset is ignored, so [] or null is only there to keep the YAML readable.
These tags are Compose specific. Other YAML tools that read the same file may choke on them or drop them, so check with docker compose config rather than a generic linter.
Further reading: Compose file reference: merge