Ok, This was annoying me for past 3 months. Every time I wake my computer from sleep, it will not recognize the network. Only way to re-establish is either by waking up from sleep before docking or disable/enable network card. Mine is also HP Elitebook 840 G1 laptop with Intel I218-LM NIC. I think i found the answer to this mystery.
Go to Properties -> Advanced -> "Wake on Link Settings" to "Forced". As soon as i set this setting, the link became active and obtained the IP address. By default it is set to disabled. I am going to see if i get consistent results, but this is the first time i have had any success with this NIC.
BTW My driver version is 12.11.77.0