It seems that docking beams will hit the entity docked on your target even if that docked entity is not visible to you (->targeting a block but hitting the docked ship behind)
(the grey and glass blocks infront are targeted by the docking beam, the yellow blocks behind belong to a second entity docked)
Beam works normal if there isn't anything behind
Beam hitting the docked blocks behind (has nothing to do with the glass blocks, it will pass through as many blocks as there are if the docked entity is in range of the beam)