Andrew Whiteford, 31, had been free nine months when he robbed a village shop in Dumfriesshire at knifepoint.
He apologised after holding up the Co-op in Kelloholm in August.
Whiteford must serve 40 months before he is eligible for parole.  The judge told him not to assume he would be released at the end of that period.
The lifelong restriction order, imposed by Lord Uist at the High Court in Edinburgh, means that Whiteford will be closely monitored if he is granted parole and can be returned to prison if he commits any further offences.
Whiteford, who was first jailed for robbery when he was 18, was assessed as posing a high risk to the safety of the public.
The judge said: "It seems that nothing will stop you committing armed robbery."
The drug addict had earlier admitted assaulting a shop assistant and robbing her of Â£300.42 while brandishing a knife.
The court had earlier heard that he bought a yoghurt before demanding the cashier put money in a bag.
As he left he said: "I'm sorry about that."
Whiteford's defence counsel said he robbed the shop to pay off a drugs debt.
He had robbed another employee at the same shop in 2011 and was sentenced to four years in prison.
An armed robber has been jailed indefinitely after targeting the same store that earned him his previous spell in prison.