It's complicated! The people who you refer to as volunteers may legally be classed as unpaid workers or employees.
For instance, it used to be believed that asylum seekers were not allowed to volunteer, but recent updates to the guidance now encourage voluntary work (Permission to work and volunteering for asylum seekers).
Asylum seekers are encouraged to volunteer whilst their claim is being considered. Volunteering involves spending time, unpaid, doing something that aims to benefit the environment or someone (individuals or groups) other than, or in addition to, close relatives.
The guidance is that you must be careful it is genuine volunteering, not just 'working for free' (because the loophole here is that you 'volunteer' at a friends' restaurant, and they pay you in kind.
...volunteering must not amount to unpaid work, or job substitution. In particular:
there should be no payment, other than reasonable travel and meals expenditure actually incurred (not an allowance for the same)
there should be no contractual obligations on the volunteer and they should not enjoy any contractual entitlement to any work or benefits
the volunteer is helping a registered voluntary or charitable organisation, an organisation that raises funds for either of these, or a public sector organisation
volunteering is not a substitute for employment, that is fulfilling a role that a salaried worker would normally fulfil
So, it is very context dependent, and your example may fall down on your last point. The linked document refers specifically to asylum seekers, but as a class of people who are not otherwise entitled to work in the UK I think it's a good place to start; as they say;
Organisations need to be clear about the legal status of volunteering roles they create before they recruit people to such roles. The guidance above is to help organisations understand the distinctions. However, if in doubt about whether a specific opportunity constitutes engagement as an employee or worker or volunteering, organisations should seek independent legal advice before taking on volunteers who are asylum seekers and who do not have permission to work.