Does the "messages from iphone" icon only appear in the dock when my messages are opened from my iPhone?
It could be, if your iPhone was around (within the same Wi-Fi range as your Mac), but one could never be 100% certain, as it could be a bug in Handoff.