Ubuntu: After login let user work in a container

I’m currently pondering setups for home office. At the moment I’m using my main profile on my home PC for both private and work things.

My plan was to separate this into two users boldewyn (private) and boldewyn-work (work).

However due to my work I need to manage, install, uninstall, ... lots of software, with some interfering with my private needs. A separate profile doesn’t help in case of system-wide software installations.

Therefore my idea was as following:

  1. Set up a Docker container with a Ubuntu Desktop running inside.
  2. Set up the boldewyn-work user on the host.
  3. When boldewyn-work logs in, the container starts, the UI is “switched” to the one of the container and every work is done inside the container.
  4. When boldewyn-work logs off, the container is automatically shut down.

What steps would be necessary (X11/Wayland connection to the container, automatic start, ...) for such a setup? Is it feasible or is there perhaps an existing or better solution?


Apart from the difficulties in gettings an entire system to work properly in Docker, it's meant for single-process programs like microservices. It will not provide you with services like systemd, and if you stop/remove the docker container and restart it, you'll lose all your changes (yeah, there are persistent loopback volumes, but that's not going to work for system folders). Docker really wasn't designed for this use-case.

A much better solution would be to use a virtual machine. For most work applications, this will suffice (unless you need 3D rendering or other "odd" things).

Either VirtualBox or KVM+SPICE should suffice in this case. Just install another Ubuntu in a VM and set up a separate login profile on the host operating system with a script that automatically launches the VM.

Not sure if you've considered it, but dual boot would also be an option of course.