I have read a number of posts about the best ways of "getting rid" of duckweed in an aquarium. While I realize these threads are mostly from quite a while ago, and even though the suggestion to throw it on the compost pile was a step in the right direction, it seems to me that most are going about this all wrong.
Instead of looking at the duckweed as a problem, why not look at it as a blessing in disguise?
Duckweed is essentially a form of water lettuce in miniature, so providing you aren't using noxious chemicals in your aquariums - which you shouldn't be anyway for the sake of your fish and invertebrates - why not simply strain it out and throw it on your salad? Okay, you can rinse it first. Microgreens are currently in fashion, they are highly nutritious, much more so than their full-sized counterparts, and you can't get a whole lot more micro than duckweed. It is also a lot less work then other microgreens since you eat it roots and all.
By some estimates, duckweed is as much as 50% protein by dry weight, and it is tasty too. Since true lettuces stop producing completely in hot weather, duckweed can be a godsend during the hot summer months when the only fresh lettuce available has to be trucked in from thousands of miles away, especially since lettuces are one of the most highly sprayed crops grown. If you are doing it right, your aquarium should be pretty much organic, which is to say maintained without the need for chemical amendments, so your duckweed will be safer to eat than lettuces from the grocery store - and it's free!
And, being so tiny, it is easy to put just the right amount on a sandwich, in a wrap, sprinkled over soups or stews, in a smoothie, on a salad or wherever else your imagination and creativity take you, no tearing or chopping required, while getting some of the delicious leafy green vegetables that so many of us are lacking in our diets. Because duckweed is so prolific, it can be a real boon to the family diet, saving money and increasing nutrition at the same time. And even kids that don't usually like vegetables generally like duckweed, so that's another win.
Or you can start raising fish that are plant eaters, such as tilapia, for food or as pets. Tilapia and other vegetarian fish LOVE duckweed, as do chickens and other birds, so if you're growing a fair amount of duckweed you can cut down substantially on your feed bill while increasing their nutrition overall. Win/win.
You can even dehydrate duckweed in a food dehydrater, or on a window screen in the shade on a nice day, and powder the dried duckweed to feed to fish fry. It is a protein rich food suitable even for carnivorous fry. I know several people who keep tanks of duckweed growing specifically to stage their vegetarian fingerlings for a month or two, once they are past the fry stage, while growing them to a larger size. Many species can grow very quickly on duckweed alone.
The main caution with duckweed, as you have already discovered, is never to introduce it into a tank where you do not want it, which is even more reason to always keep a staging tank for any new fish or plants, before moving them to your primary aquarium.
Never introduce duckweed, or any other non-native plants or animals into a waterway, as they can out-compete native species and cause them to decline.