The original question has already been answered, but it mentioned London Gateway and I thought this might be some interesting background information on container loading there:
There is a lot of information online about how the port and rail terminal operate. On the port website -
https://www.londongateway.com there are rail schedules and vessel schedules showing arrivals and departures. DP World (port operators) have a Youtube channel which explains various operations at the port in different videos. There is also this speeded-up cab ride along the branch into the terminal:
Boxes are offloaded from ships onto the dockside by the giant quay cranes and then moved by straddle carriers to an automated container stacking area which also loads lorries. Containers for the rail terminal are moved from the stacking area by internal port tractor-trailer units, and left on their trailers to be picked up by the gantry cranes in the rail terminal.
These videos, watched in this order, show the general sequence from ship to train (I'll link the channel rather than all the individual videos) -
https://www.youtube.com/user/londongateway/videos
DP World London Gateway operations on Barzan, one of the world's largest container vessels [ship unloading]
DP World London Gateway Quayside Loading and Unloading
Episode 2 London gateway: Living the High Life [Quay crane operator]
Episode 4 London Gateway: Stacks of choice [Terminal tractor movements, stacks to rail terminal]
Episode 5 London Gateway: Working outside the box [Gantry crane operator in rail terminal]
DP World London Gateway - Rail Operations
DP World London Gateway Rail Terminal Time-lapse [Train loading and unloading]
Clearly there is pre-positioning of containers (which will be based on a loading plan) so that the cranes don't have to wait for them, or constantly shuttle backwards and forwards along the length of the train. I think there's a mix of factors already mentioned that determine loading patterns - the ideal of loading containers from the loco backwards to minimise wind resistance, vs the various weight and container height restrictions of different wagon types, and the desire of the terminal or port to make the loading as simple and efficient as possible for themselves, with often limited time for unloading and reloading. Add in the occasional defective wagon that can't be loaded, a mix of wagon types, a few containers which missed the cutoff time, and you get a puzzling end result of apparently random gaps on some trains.