“Like a cap on the jug with a hose connected”
that’s one way to skin the cat.
If the jug is a 5-gallon (or 3.5-gallon) glass carboy, that method works well because of the large hose diameter. The outlet end of the hose should be submerged in a bucket containing water and some unscented bleach (as a sanitizer). Something along the proportions of 1/4 cup bleach added to 5 gallons of water (though not necessarily that quantity).
If using a gallon jug, the smaller diameter hose in the cap will plug easily, resulting in a big honkin’ mess (overflow (bad) or explosion (really bad)). I usually use a large planter tray (~ 24” diameter) to set my fermenter on to catch overflow.
Skip the cap and use a hose with a large enough diameter to fit snugly inside the mouth of the jug. Avoids (bad) and (really bad) situations.