The detection being used works for the "mothership", the entity where the rail docker is docked to. It does not work for other docked entities though, see screenshots:
Left rail docker has a core placed on the right rail docker: ship core spawned on it so there's z-fighting:
{F1481}
Was able to left click and lock its position down, normally it gives you an error message that the selected place is occupied:
{F1483}
How to reproduce:
# place down 2 rails
# use the "create dock" on both, the second time you use it, select an occupied block of the 1st ship you placed down.