Sign inSign up

magic4wei/ubuntu

By magic4wei

Updated over 2 years ago

Ubuntu base images used for development and tests. Support OpenGL rendering with tag `gui-base-*`.

Image
1

333

magic4wei/ubuntu repository overview

Installed Packages

Ubuntu base images magic4wei/ubuntu:base-* are built on top of ubuntu:<distro>.

Some packages are installed for more convenient development and test:

  • Utils: apt-utils, lsb-release, ca-certificates openssl
  • Download files: git, wget, curl
  • Archive, compress and uncompress: tar, gzip, lzip. bzip2. xz-utils, lzma, lzop

Additional GUI-related packages are installed in Ubuntu GUI base images magic4wei/ubuntu:gui-base-* to enable OpenGL rendering and X display.

Usage

Explore Ubuntu Base Images

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
Work with OpenGL Rendering

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

  • at least one GPU is mounted on your machine
  • GPU driver is installed correctly
  • You can run 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:

  1. Run image with Nvidia driver volume bindings
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
  1. Add Nvidia OpenGL library path in the container
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

Tag summary

Content type

Image

Digest

sha256:1c93c2d25

Size

130.3 MB

Last updated

over 2 years ago

docker pull magic4wei/ubuntu:gui-base-22.04