ERROR: error while removing network: network xxxxx-network id 3f87f2b83581e8e8a80f43dcfde95f0275659404bdf2001d6cf9871b4522caa5 has active endpoints
This is a stale endpoint case.
Do you happen to have the error log when that container that was originally removed (which left the endpoint in this state).
BTW, if the container is removed, but the endpoint is still seen,
then one can force disconnect the endpoint using docker network disconnect -f {network} {endpoint-name} .
You can get the endpoint-name from the docker network inspect {network} command.
https://github.com/moby/moby/issues/17217#issuecomment-196607597