Pack the onions in 2 1-quart jars and cover with water to come within a half inch of the rim. Pour the water out into a measuring cup. Note the volume, pour off half the water, and replace it with vinegar. Add 2 tablespoons sugar and 2 tablespoons salt for every 3 cups of liquid. Pour the vinegar mixture into a nonreactive saucepan, add the mustard seeds, red pepper flakes, coriander seed, black peppercorns, garlic, and bay leaves and bring to a boil over high heat. Allow the liquid to boil for 2 minutes, and then remove it from the heat.
Pour the hot liquid into the jars to cover the onions and screw on the lids. Refrigerate for up to 1 month.