Running GUI apps within Docker containers
trickster.dev
trickster.dev
docker run -it --rm -e DISPLAY --net=host -v $XAUTHORITY:/root/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix debian:11-slim
Then inside the container, run:
apt update
apt install firefox-esr
firefox
Now Firefox runs inside the container but displays on your hosts screen and you can use it right away.Here's the equivalent Dockerfile + docker-compose.yaml for convenience:
# Dockerfile
FROM debian:11-slim
RUN apt-get -y update && apt-get -y install firefox-esr
CMD ["firefox"]
# docker-compose.yaml
services:
firefox:
image: firefox
build: .
environment:
DISPLAY: ${DISPLAY}
network_mode: host
volumes:
- ${XAUTHORITY}:/root/.Xauthority
- /tmp/.X11-unix:/tmp.X11-unix
This way you can run it with just: docker-compose upThe example above is writing and reading every X11 message over a socket, and not reaching into /dev on the host, else it would need additional parameters added to the docker command.
I'm not current on Wayland, but as of a few years ago all attempts to run it non-locally required the X11 back-compat layer. I have no idea what /dev nodes would be required to be shared for wayland to run in a chroot.
docker run -e XDG_RUNTIME_DIR=/tmp \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
--user=$(id -u):$(id -g) \
imagename waylandapplication
Pretty simple and reasonable really, just needs to use the same Wayland socket and (in order to access it) user ID. From:
https://unix.stackexchange.com/a/359244I suppose if you were adventurous you could give it whatever other known user ID, and start a separate Wayland compositor for it. But I don't know why you would, when surely the point is to get containerised GUIs visible to you alongside others. Containerised multi-seat I suppose?
It could be made less verbose by encapsulating in a compose file, or by removing the env var to point into /tmp and instead using whatever the default is for the chosen image. Also it's not necessary to specify the value for an env var being passed through with the same name (I just copied from SO).
Transports
To date all known Wayland implementations work over a
Unix domain socket. This is used for one reason in
particular: file descriptor messages. Unix sockets are
the most practical transport capable of transferring file
descriptors between processes, and this is necessary for
large data transfers (keymaps, pixel buffers, and
clipboard contents being the main use-cases). In theory,
a different transport (e.g. TCP) is possible, but someone
would have to figure out an alternative way of
transferring bulk data.
So, that is why I hear about needing X11 compat for remote connections; wayland connections are still sockets (not e.g. shared mem), but they require the ability to pass file descriptors through the socket, which can only be done with Unix sockets. (and those file descriptors provide access to shared mem)I don't see any details about how this interacts with OpenGL, like whether indirect rendering is possible or if applications would need /dev mounted.
I'm a little surprised the examples don't require fiddling with X permissions, which I always had to do when not using ssh.
Yes, but GP's example is X over a unix socket. Not sure if that counts as network.
Because in practice it generally can't; I'm not aware of any Linux distribution not shipping their X server with `-nolisten tcp` by default.
On the other hand the use cases that the article describes can already be accomplished by Firefox's "account containers" feature or just creating another profile and running `firefox --no-remote`
If you pass the GPU device node through to an LXC container I believe you can run an X or Wayland server fully inside of it but I'm not sure if changing ttys will work correctly because you might need access to more than just the GPU to handle the handoff with the kernel correctly.
1. That's a big "if"; I'm fond of docker precisely for fixing software availability issues.
2. It's diminished, but it still provides significant protection, since the containerized program still can't see the real filesystem or process table without going through X or something networked. That's still pretty significant; it would, for instance, protect against a Firefox zero-day that was being used to read people's private SSH keys (not a hypothetical; that incident is what pushed me personally to start sandboxing my browser).
I don't deny that in theory someone could deploy a Firefox zero day that steals ssh keys and that having an abnormal setup via docker could throw a wrench in that, but you are essentially relying on obscurity of your setup which is not an acceptable approach - in the same way that the obscurity of TempleOS would not be a good security approach.
Where beginners in security wrongly rely on it entirely
Then intermediate experts proudly proclaim that it's not acceptable
Then expert experts realize it's an excellent part of defense in depth.
-
I mean I know it's a hyperbolic example in your comment, but do you really think leveraging the obscurity of TempleOS wouldn't be an extremely potent way of dodging 99.99999% of malware in existence?
Forcing a tailored attack to breach your isolation is already miles ahead of just running it on your desktop and is most certainly an "acceptable approach", even if it's not infallible.
For example: if you're hosting a self made shopping cart versus an open source/commercial product, there's probably a higher risk of being vulnerable to SQL injections. It's conceivable that open source and commercial offerings have been beaten on more and as a result hardened against more attack vectors.
Of course to your point, it means that you're not vulnerable to a zero day that impacts many deployments. I imagine the shops that made their own logging library were quite pleased with themselves when the log4j vulnerabilities came out.
My point being that it's not a simple calculus, and it's really hard to evaluate the relative risks of one versus the other. It's probably best to look at the cost of implementing and maintaining security through obscurity and using that as a litmus test for if it's reasonable or not.
Running something on a non-standard port has a very different cost than making your own operating system.
Backup there. I somehow have not heard about this. What was the vector? What was the exposure? E.g. have I leaked the contents of ~/.ssh to some (hopefully small, at least) subset of sites I've visited? Where can I learn more?
https://www.x.org/releases/X11R7.6/doc/xextproto/security.ht...
>By using this software you agree that the following non-PII (non personally identifiable information) data will be collected, processed and used by the maintainers for the purpose of improving the docker-android project. Anonymisation with respect of the IP address means that only the first two octets of the IP address are collected.
https://github.com/budtmo/docker-android/blob/master/LICENSE...
How can you call a project Apache when you're forcing people to pay via their data ? Why is their no opt out option?
Absent that this seems like a great QA automation tool. Or a Tinder bot farm...
Just rubs me the wrong way, you can easily use this without knowing it phones home
Having a full blown container like this can be useful in some scenarios, but I think it’s overkill for general purpose apps.
This can also be accomplised by using Firefox's Multi-Account Container extension in conjunction with the Container Proxy extension.
The Multi-Account Container extension is also great for non-dirtbag purposes. For instance testing different user profiles in an application - create 1 container for User, 1 for Admin etc.
The article says you need a compatible image for that, but in my experience, everything launches just fine.
[1] https://github.com/microsoft/vscode-dev-containers/blob/main...
You can even have a whole systemd setup in a container using this VNC backend, here in this Dockerfile with CPU rendering (LIBGL_ALWAYS_SOFTWARE=1) to avoid requring a GPU:
FROM docker.io/fedora
RUN dnf -y update && dnf install -y phosh phoc wayvnc sudo socat iproute mutter xorg-x11-server-Xwayland dbus-x11 mesa-libgbm mesa-libOpenCL mesa-libGL mesa-libGLU mesa-libEGL mesa-vulkan-drivers mesa-libOSMesa mesa-dri-drivers mesa-filesystem gnome-shell gnome-terminal
RUN mkdir -p /etc/systemd/system/phosh.service.d && echo -e '\
[Unit]\n\
ConditionPathExists=\n\
[Service]\n\
Environment=WLR_BACKENDS=headless\n\
Environment=WLR_LIBINPUT_NO_DEVICES=1\n\
StandardInput=null\n\
TTYPath=/dev/console\n\
TTYReset=no\n\
TTYVHangup=no\n\
TTYVTDisallocate=no\n\
ExecStart=\n\
ExecStart=/usr/bin/phoc --exec "bash -lc \"/usr/libexec/phosh --unlocked & wayvnc 0.0.0.0 7050\""\n\
' > /etc/systemd/system/phosh.service.d/10-headless.conf
RUN systemctl enable phosh.service
# Work around a problem with a missing dbus.service unit file
RUN mkdir -p /etc/systemd/system && ln -fs /usr/lib/systemd/system/dbus-broker.service /etc/systemd/system/dbus.service
# Mask udev instead of making /sys/ read-only as suggested in https://systemd.io/CONTAINER_INTERFACE/
RUN systemctl mask systemd-udevd.service systemd-modules-load.service systemd-udevd-control.socket systemd-udevd-kernel.socket
ENV container=docker
RUN groupadd --system sudo
RUN useradd --create-home --shell /bin/bash -G sudo user
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
ENV LIBGL_ALWAYS_SOFTWARE=1
RUN sudo -u user gsettings set sm.puri.phoc auto-maximize false
EXPOSE 7050
# Set up a /dev/console link to have the same behavior with or without "-it", needs podman run --systemd=always
CMD [ "/bin/sh", "-c", "if ! [ -e /dev/console ] ; then socat -u pty,link=/dev/console stdout & fi ; exec /sbin/init" ]
Use as: podman run --systemd=always --rm -p 7050:7050 imagenameAh (edit), there it is:
Because if most tools belong to the VM, then just run a VM in full screen and use that. No need to have the display server shared if you're using mostly Linux tools that display on the VM's X server.
https://blog.jessfraz.com/post/docker-containers-on-the-desk...
[0] I was exposed to it via Fedora Silverblue, where something like it is a necessity since the base OS is immutable. I've found it very useful even outside that use case however.
[1] Seems to me you could even use bwrap if you were reluctant to use syscalls directly.
[2] having done a little research towards creating my own tool because I'd rather not depend on a package that isn't available in many LTS distros, among other reasons.
They have told users that if they want, for instance, Jetbrains IDEs to work, they should simply get a Job at Jetbrains and convince them to rewrite their entire IDE to support the flatpak model.[1]
This is the reason I avoid distros with Flathub enabled by default. Half the software on there is broken in some pretty subtantial way, and nobody at Flatpak or Flathub cares. They really need to realize they're not Apple, they simply can't tell everyone to do things their way and hope to build a working and reliable ecosystem.
They have the equivalent to snap's classic confinement, but it needs to be explicitly enabled every time you launch an app.
[1]: https://github.com/flathub/com.jetbrains.IntelliJ-IDEA-Commu...
Personally I like that the Linux Desktop community is finally starting to wake up to the idea of universal application distribution that doesn't require armies of unpaid third party maintainers, and while Flatpak is definitely not perfect it is, in my opinion, a huge step forward in that regard[0].
[0] Not that the idea is really that new, there have been many attempts at bringing sanity to Linux application distribution, many of them better (IMO), but they've just never really been embraced by the community the way Flatpak has.
The person I linked above is in fact a flatpak maintainer.
Also, I hate they are shipping broken software. Almost nothing in that IDE works properly, yet Fedora now shows it by default when I search software.
At least snaps work most of the time.
The main mistake you're making is thinking that Flatpak imposed this design constraint, when really it's a fundamental property of the underlying OS, that sandboxing solutions are forced to work around. It's possible to fix this with a distribution built in a very specific way like NixOS where you can theoretically mount different systems together, but that comes with it own sets of problems and things that it breaks.
It makes me want to rip out flatpak from every system I see.
You could make a curated repository but that would just be taking flathub and removing a lot of packages.
Personally I just layer my IDEs with ostree as a compromise.
Using a Docker container, which you may already have anyway, putting CPU/RAM quotas is a one-liner.
I do this to put many of my resource hungry apps like FF in slices.
Here’s an example of one, https://github.com/accetto/ubuntu-vnc-xfce-g3
Novnc just allows accessing things via a browser too. I use it for quick checks but VNC when I want a client
As an aside, instead of talking about growth hacking, and OSINT I think this whole thing could be a lot more relatable if the author chose a simple motivation like privacy. Another comment here mentioned subtools (?) which clearly highlights that not everything should be trusted with full access to your system.
It just lets you reuse any docker image on your desktop (both podman and docker), and has some nice features like the ability to create a launcher shortcut on the host and transparently mapping your home directory. I switched to it full time, all my CLI work is just done in a container, and it's pretty transparent.
Edit: this method uses xquartz on the Mac side, and socat to bridge between a network port and a file socket.
ps. you know, for some people it's very hard to read bright text on black background. Especially if you're flipping from opposite contrast.
if docker version is >20.10.x also works with Linux
Ugh, sounds like the software equivalent of using a huge stack of ingenious hardware to just do something parasitic like high-frequency trading.
Fast capitalism, to me, seems to be an ideology entirely centered on an authoritarian we-versus-them mindset where profit is king, civilian collateral be damned.
At the top of growth is incumbency. I think that’s where your second paragraph comes in. Incumbents surveil innovations, and “growth hackers” don’t like to talk about this obvious conclusion. They’d rather inhabit a role that concludes once growth has succeeded and slowed.
This is no more revolutionary than traditional marketing. Marxism talks about capitalist marketing as a way to channel alienation among working classes away from collective organization. But, Marx from the beginning needed to market his ideas to different groups. He needed those groups to realize that they needed his political orientation. He tries to do this with abstractions, and explicitly gives up on whole classes he deems unfit to understand those ideas (the lumpenproletariat).
As the product of a growth hacker reaches incumbency, marketing gives way to public relations. We might consider Cambridge Analytica public relations hackers. Same level of statistical sophistication, same single-focus of corporate promotion over all other advancements.