Floatation: Soil/Dirt/Saturated dirt is very heavy. I would calculate assuming saturated soils with a unit weight of 100lb/CF or something. You don't want it to sink the first rainstorm you get. Each 5 gal bucket only provides 42lb of buoyant forces. Including all the framing you would want at least two submerged buckets for every garden bucket. Not worth it on this scale but they actually make lightweight garden soil for rooftop gardens with pumice sand/high peat content. For this just get something with a high peat moss content.
Gardening: Not sure how much experience you have bucket gardening, but I would go with more area, less depth. Like I would plan to soil the entire top of your dock with 8" of soil evenly distributed. Reason's being the smaller the pot, the more trouble I have keeping the plant evenly watered. Most garden annuals don't grow that deep.
I've been looking into foam sheets more. I realized I could layer some together and then shrink wrap over them (the thick white wrap used for storing boats in winter) so it would look nice and not degrade in the elements too much.
One 2"x4'x8' foam sheet is about 5.4 cubic feet of area. Assuming water is 60lbs/cuft (it's a bit more but varies by temperature), 326lbs of water is displaced by submerging it.
Each bucket holds about 1cuft of soil, 100lbs when wet. (I looked it up, it's 80-110lbs so 100 seems reasonable for estimation.) So I'd need 1 sheet of foam for every 3 buckets. This assumes complete sheets are used, but if I cut them on a diagonal I can probably get two layers out of each sheet, so that's just fine. So for 9 buckets, 3 sheets of foam, and the raft would be 12 inches thick.
(Cost: $90 for 3 foam boards, $20 worth of shrink wrap, plus some kind of mat for the top. So $110-$130 or so. I'm expecting actual cost to be a little more because projects always blow up somehow.)
I'll see what other containers can be had cheaply. If I find a way to go wide and shallow, maybe just setting them on the dock will work, since they'd be less vulnerable to getting blown down in the wind then. We're both working from home for the foreseeable future, so frequent watering needs aren't too much of a problem.