Ubuntu base images used for development and tests. Support OpenGL rendering with tag `gui-base-*`.
333
Ubuntu base images magic4wei/ubuntu:base-* are built on top of ubuntu:<distro>.
Some packages are installed for more convenient development and test:
Additional GUI-related packages are installed in Ubuntu GUI base images magic4wei/ubuntu:gui-base-* to enable OpenGL rendering and X display.
Get started with base image magic4wei/ubuntu:gui-base-* If you want to run a GUI application that requires OpenGL rendering (see tutorial below). Otherwise magic4wei/ubuntu:base-* would be better since it has smaller size.
Explore Ubuntu base images by running
# Ubuntu 18.04 for example
docker run -it --rm magic4wei/ubuntu:base-18.04 # no OpenGL rendering is supported
docker run -it --rm magic4wei/ubuntu:gui-base-18.04 # enable OpenGL rendering, see tutorial below
Base image magic4wei/ubuntu:gui-base-* have already installed required packages to enable OpenGL rendering in container. Before you go through this tutorial, make sure that
glxgears in terminal without any error (package mesa-utils is needed)Firstly, you need to run xhost + on your host machine to enable X client display.
For Intel GPU, simply run
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--privileged \
--device=/dev/dri:/dev/dri \
magic4wei/ubuntu:gui-base-18.04
For Nvidia GPU, it is a little bit more complicated. We need to connect Nvidia driver volume when docker image runs, and add Nvidia OpenGL library path to LD_LIBRARY_PATH inside the container. If you want to run Nvidia executable tools like nvidia-smi, you also need to add their path to PATH inside the container.
For example, I have installed Nvidia driver nvidia-430 at /usr/lib/nvidia-430 and /usr/lib32/nvidia-430 (32-bit compatible libraries), and all my Nvidia tools are located at /usr/lib/nvidia-430/bin. Two steps to enable OpenGL rendering in container:
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--privileged \
-v /usr/lib/nvidia-430:/usr/hostLib/lib/nvidia \
-v /usr/lib32/nvidia-430:/usr/hostLib/lib32/nvidia \
magic4wei/ubuntu:gui-base-18.04
export LD_LIBRARY_PATH=/usr/hostLib/lib/nvidia:/usr/hostLib/lib32/nvidia:${LD_LIBRARY_PATH} # required for OpenGL rendering
export PATH=/usr/hostLib/lib/nvidia/bin:${PATH} # optional, add this if you want to run tools like nvidia-smi
Then you are able to run GUI applications that requires OpenGL rendering in the container. For example,
# Example: Run glxgears (needs `mesa-utils`, already installed in GUI base images)
glxgears
Content type
Image
Digest
sha256:1c93c2d25…
Size
130.3 MB
Last updated
over 2 years ago
docker pull magic4wei/ubuntu:gui-base-22.04