The dream vial is obtained in the Dream Mentor and Dragon Slayer II quests. The Oneiromancer gives the player an empty Dream vial.
To make the potion, the player fills the Dream vial (empty) with water to create a Dream vial (water) - The easiest way to fill the vial after obtaining it is in the house south-west of the bank on Lunar Isle. Next, add a Goutweed (either grown through Farming or stolen at the Troll Stronghold) to create a Dream vial (herb). Finally add ground astral rune (use a hammer on an astral rune, then crush the shards into dust with a pestle and mortar) to make the Potion of Shared Dreaming.
With the potion, the player can travel to a Dream World in Dream Mentor or Dragon Slayer II, and sort out either Cyrisus's fear of combat in Dream Mentor, or Bob's past in Dragon Slayer II, where the player faces high-levelled monsters representing the respective quests' issues.
Warning: The dream vial is lost upon death and you will need to acquire a new one.