0

Boot2docker is a lightweight Linux distribution running in VirtualBox VM. All basic functionality works fine, I am able to use docker containers in MacOS X.

However my application requires OpenGL rendering and I cannot get it working. How do I control which graphics acceleration is used inside that VirtualBox VM? I want to completely remove any 3D acceleration functions, because Mesa software drivers should just work perfectly (tested on VMware VM).

Is there a way to control boot2docker VM graphics settings like I do for normal VirtualBox VMs?

Aleksei Petrenko
  • 6,698
  • 10
  • 53
  • 87

2 Answers2

1

I'd say the most straightforward way (and I'd place this as a feature/bug request with the boo2docker devs) would be to install a pure Mesa llvm softpipe build for OpenGL. This should give you OSMesa. However for a classical OpenGL context you'll probably need some kind of X server (until EGL / offscreen Wayland works satisfactory). A X.org server with a dummy device should work perfectly, as long as you use framebuffer objects.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Hi, thank you for the answer. Now I understand the problem better and I'd maybe ask a slightly different question. What I really need is a Docker container that is independent of the graphics hardware of host system. It should run on physical PC and on VM, so I just want to use software emulation ALWAYS. Is there a way to create such container configuration to ensure that I always use only software OpenGL rendering? – Aleksei Petrenko Sep 28 '14 at 19:48
  • Also, how do you run "dummy" X server and what does it mean? – Aleksei Petrenko Sep 28 '14 at 19:49
  • 1
    @AlexPetrenko: With a sufficiently new installation of Mesa, as soon as you try to create an OpenGL context without a supported GPU being available, you'll drop into the "softpipe" fallback implementation. Currently the majority of Linux libraries that in some way make use of OpenGL are built in a way, that they need a running X1 server to work (the X server is the traditional graphics system used in Linux; Wayland is the successor-to-be infrastrucure). The X server have *some* graphics device configured. And for systems with no physical graphics output that's a *dummy* device. – datenwolf Sep 28 '14 at 20:03
  • 1
    @AlexPetrenko: In principle you could also use a virtual framebuffer X server. But if you're targeting your application to render on a framebuffer object using the Mesa softpipe, then you can get away with just a dummy screen. –– another, totally viable option that does not require an X server, but limits your choice of framework libraries is using OSMesa: http://www.mesa3d.org/osmesa.html – datenwolf Sep 28 '14 at 20:06
  • The problem is that it would be very difficult to update code to use these OSMesa context creation functions - I don't want to do it. Ideally I'd use mesa drivers and just start X server, but I have a lot of problems with it: http://stackoverflow.com/questions/26075741/starting-xserver-in-docker-ubuntu-container – Aleksei Petrenko Sep 28 '14 at 20:34
  • Can changing "device" in xorg.conf to 'dummy' make any difference? Also, when you say "X1 server", do you mean "X11"? – Aleksei Petrenko Sep 28 '14 at 20:34
  • @AlexPetrenko: Yes that was a typo. Of course X11. The error you're seeing happens if you start the X server as non-root user and the X binary is not SUID root. Technically the condition leading to this error is an anachronism and on a modern Linux system the X server can perfectly fine be started by an unprivileged user. – datenwolf Sep 29 '14 at 01:43
0

It turns out that boot2docker is just a wrapper around the VBoxManage command. And if you really want to, you can control the VM created by boot2docker using VBoxManage command - you can change 3D graphics acceleration, VMem, etc.

Aleksei Petrenko
  • 6,698
  • 10
  • 53
  • 87