Problem with cassette and derailleur
You can't use an 8 speed shifter with a 10 speed cassette. The space between individual cogs is smaller than on an 8 speed cassette. The shifter moves the derailleur a fixed distance per shift, so it can't reach the position of the cogs if they are not spaced as intended.
The fact that you can use the 4 biggest and the smallest gear is pure luck, because the derailleur seems to match those positions good enough to make it work.
In conclusion, try to find an 8 speed cassette that fits on your trainer.