This is the story of Luffy becoming the Pirate King.
At that time, because he left his companions, he was too hungry and ate a poison called nightmare.
Luffy has a physique that can compete with poison.
So Nightmare couldn't defeat Luffy.
The nightmare that Luffy dreamed of was just a hint of the poison...