Volunteering by an international student on a F1 visa is permitted and encouraged by immigration! But remember that a student on a F1 visa cannot receive any form of income from the volunteering.
You also can’t volunteer if the position is one that the company would have otherwise hired someone for the position.
For some great examples of volunteer work that F1 students can do without issue, read more here.