Using Container only on Linux

I have a matrix job that uses both ubuntu-18.04 and macos. But on Linux I don’t want to use the VM directly and would prefer to use a container instead.

Is there a way to specify a container only if the matrix is using ubuntu and not on macos?

Paulo

Similar topic: https://github.community/t5/GitHub-Actions/Run-matrix-job-on-macos-and-on-ubuntu-in-container/m-p/37013#M2772

Thanks - marking your reference as solution since this is a duplicated issue.