By virtual environments, I mean Linux containers like Docker and Vagrant and not full blown VirtualBox.
So, the issue is that I often have to install packages from untrusted sources in my Ubuntu. However, lately I've become paranoid about these applications, and have been thinking about limiting their access or running them in SandBox.
Here is one scenario which I have been considering:
If I install an untrusted package on my machine and use SELinux/AppArmor for securing it, and this package needs to connect to the network, how can I be sure using SELinux that the package is not sending my key-logs or any other such information over the Internet? In this case, it seems like if I run the app in a separate Docker environment, it would be safer because then it would not have access to my keystrokes or any other such information.
There are many other scenarios too. But my question is this : in general, which provides better security of these two options? What exactly are the security layers/measures provided by these two methods?