A plant that thrives in the ground and fails in a pot is almost always suffering from one of a short list of problems. Working through them in order usually identifies the cause within a few minutes, and prevents repeating it.
1. It dried out
The commonest cause by a distance. A pot has no reserve, and a single hot day without water can be enough for a small container.
The awkward part is that dried-out peat-free compost then repels water, so subsequent watering runs down the gap between compost and pot and out of the base without wetting the rootball at all.
Check by pushing a finger in rather than judging the surface, and rescue a dried-out pot by standing it in a bucket of water for half an hour.
2. It was waterlogged
Confusingly, this looks almost identical: wilting, yellowing and collapse. Roots deprived of oxygen cannot take up water, so the plant behaves as though it is thirsty.
Feel the compost. Wet and heavy, possibly with a sour smell, means the opposite problem. Check that drainage holes are not blocked, that the pot is not standing in a full saucer, and that it is raised on feet.
Winter is when this does most damage, since pots collect rain and plants use very little.
3. The compost ran out
Fresh compost feeds a plant for about six weeks. A plant that grew well in May and stalled in July has usually simply exhausted its food supply.
Feed weekly through the growing season with a balanced liquid feed, switching to high-potassium once flowering starts, and top dress permanent plants each spring.
4. It is pot bound
Roots circling tightly around the inside of the pot, water running straight through, and growth stalling despite feeding.
Tip the plant out and look. A solid mat of coiled roots with little compost visible means it needs a larger pot, or root pruning and fresh compost if it is at its final size.
Tease circling roots outwards when repotting, or cut through them in three or four places, since roots left circling continue to circle.
5. Vine weevil
A healthy-looking plant that collapses suddenly and comes away in your hand when tugged has usually lost its roots to vine weevil grubs.
Tip it out and look for creamy white C-shaped grubs with brown heads in the compost. Adults leave distinctive notches in leaf margins.
Apply nematodes in late summer, repot into fresh compost, and check the rootball of any new plant before it joins the collection.
6. Frost damaged the roots
Roots in a pot are far more exposed than roots in the ground, since cold penetrates from every side. A plant hardy in a border may not be hardy in a container.
Move pots against a house wall for winter, wrap the container rather than the plant, and raise it on feet so it is not standing in freezing water.
7. Wind and position
A tall plant in a light pot blows over, breaking stems and drying the rootball. Wind also scorches foliage and dramatically increases water loss.
Use heavier containers for tall plants, group pots together, and site them out of the worst wind. A pot in a windy corner may need watering twice as often as the same pot in shelter.
Two that are often missed
Wrong compost: a lime-hating plant in ordinary compost yellows steadily and never recovers until it is moved to ericaceous compost and rainwater.
Wrong size: a small plant in an enormous pot sits in a mass of unused wet compost that sours, and frequently rots. Pot on one size at a time.
Before you replace it
Tip the plant out and look at the roots. White and firm means the problem is above ground. Brown, soft and easily stripped means water or drainage. Absent means vine weevil.
That one check answers most questions, and it takes a minute.
Preventing a repeat
Most of these are prevented by three habits: using a larger pot than seems necessary, checking the compost with a finger rather than by eye, and feeding from six weeks after planting.
Between them those cover drought, exhaustion and pot binding, which account for the great majority of container losses.