This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Docker Container Configuration

This article describes the Docker container configuration process. Docker enables you to develop or run your UNIGINE-based application in different environments in isolation inside the container. Your computer needs to have an NVIDIA graphic card and Linux system with Ubuntu to replicate all necessary steps.

To work within other distributions, like Amazon, Open Suse, Debian, Centos, or RHEL, please refer to the NVIDIA Container Toolkit documentation.

System Requirements#

You need to shut down all the programs playing sound. The ALSA driver should be installed in the system to play the sound correctly.

Notice

The Docker daemon binds to a Unix socket, not a TCP port. By default it's the root user that owns the Unix socket, and other users can only access it using sudo (read more). The Docker daemon always runs as the root user.

If you don't want to preface the docker command with sudo, create a Unix group called docker and add users to it (read more). When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

Docker Configuration#

To configure Docker perform the following steps:

  1. Install NVIDIA Container Toolkit
  2. Get the Docker container image or assemble it yourself.
  3. Run a Docker container in test mode.

NVIDIA Container Toolkit Installation#

  1. Configure NVIDIA Container Toolkit according to its configuration documentation. Install the package repository and the GPG key, type the command line for that:

    Output
    $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
    && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
    && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
        sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
        sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
  2. Install nvidia-docker2:

    Output
    $ sudo apt-get update
    $ sudo apt-get install -y nvidia-docker2

  3. Restart Docker:

    Output
    $ sudo systemctl daemon-reload
    $ sudo systemctl restart docker

Preparing Container Image#

There is a ready-to-use container image that we have prepared for you on the Docker Hub - check out the following link run-unigine-in-docker and use the following command:

Output
docker pull unigine/run-unigine-in-docker

In case for any reason instead of using the container image from the Docker Hub you want to prepare and assemble your container image manually please follow the instructions in the spoiler below:

  1. Create a folder to work with the container:

    Output
    $ mkdir ~/unigine-in-docker
  2. Create a Dockerfile text file inside the unigine-in-docker/ folder:

    Output
    $ cd ~/unigine-in-docker
    $ touch Dockerfile
  3. Add the following lines to the Dockerfile file and save it:

    Output
    FROM nvidia/opengl:base-ubuntu20.04
    VOLUME /tmp/.X11-unix
    RUN apt update && apt upgrade -y
    
    # linux-headers- hardcoded, if it don't build - try update version of linux-headers
    RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt install -y \
    	python3 \
    	wget gnupg \
    	xvfb \
    	x11-xserver-utils \
    	python3-pip \
    	libegl1-mesa \
    	libgl1-mesa-dev \
    	libxv1 \
    	gcc g++ make ccache \
    	libxrandr-dev \
    	libxinerama-dev \
    	libopenal1 \
    	libxrender-dev \
    	libxext-dev \
    	libc6-dev \
    	libx11-dev \
    	libxi-dev \
    	libxml2-dev \
    	cmake \
    	nano vim \
    	lshw \
    	libglu1-mesa \
    	mesa-utils \
    	glmark2 \
    	xxd \
    	# for sdk bro2 \
    	libxcb-shape0 \
    	libxcb-xkb1 \
    	libxcb-icccm4 \
    	libxcb-image0 \
    	libxcb-keysyms1 \
    	libxcb-render-util0 \
    	libxkbcommon-x11-0 \
    	linux-headers-5.4.0-135-generic \
    	lxterminal \
    	# sound \
    	alsa-base \
    	alsa-utils \
    	libsndfile1-dev
    
    COPY ./asound.conf /etc/
    
    RUN python3 -m pip install pyinotify
    
    ENV XDG_RUNTIME_DIR=/tmp/.X11-unix
    
    # install dotnet and runtime
    # if it don't build - try to find more recent versions of dotnet at https://dotnet.microsoft.com/en-us/download/dotnet/6.0
    
    RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/01292c7c-a1ec-4957-90fc-3f6a2a1e5edc/025e84c4d9bd4aeb003d4f07b42e9159/dotnet-sdk-6.0.418-linux-x64.tar.gz
    RUN wget -O dotnet-runtime.tar.gz https://download.visualstudio.microsoft.com/download/pr/b63daa46-51f4-480e-ad03-ef2c5a6a2885/ae059763456991305109bf98b3a67640/aspnetcore-runtime-6.0.26-linux-x64.tar.gz
    RUN mkdir /usr/local/etc/dotnet-sdk-6.0
    RUN tar -xzf dotnet.tar.gz -C /usr/local/etc/dotnet-sdk-6.0
    RUN tar -xzf dotnet-runtime.tar.gz -C /usr/local/etc/dotnet-sdk-6.0
    RUN rm -rf /usr/bin/dotnet
    RUN ln -s /usr/local/etc/dotnet-sdk-6.0/dotnet /usr/bin/dotnet
    
    # path to libraries
    ENV LD_LIBRARY_PATH="/opt/project/bin"
  4. Create a new asound.conf file:

    Output
    $ sudo vi asound.conf
  5. Write the following script to the asound.conf file:

    Output
    pcm.!default {
            type plug
            slave {
                    pcm "hw:0,0"
            }
    }
    
    ctl.!default {
            type hw
            card 0
    }
    
    pcm.mixed-analog {
        type plug
            slave.pcm "dmix-analog"
            hint {
                show on
                    description "Mixed Analog Output - Use analog outputs, converting samples, format, and rate as necessary. Allows mixing with system sounds."
            }
    }
    
    # Control device (mixer, etc.) for the card
    ctl.mixed-analog {
        type hw
            card 0
    }
  6. Assemble the Docker image (inside the unigine-in-docker folder):

    Output
    $ docker build --rm --tag run_unigine_in_docker:latest -f Dockerfile .

Docker Test Run#

  1. Launch the container in trial mode to view GPU characteristics:

    Output
    $ cd ~/unigine-in-docker/
    $ docker run -it --rm --network host \
    --runtime=nvidia --gpus 0 -e NVIDIA_VISIBLE_DEVICES=0 \
    -e DISPLAY=${DISPLAY} \
    -e NVIDIA_DRIVER_CAPABILITIES=display,compute \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
     run_unigine_in_docker:latest \
     /bin/bash
    # nvidia-smi

  2. Check selected GPU drivers with the following command: glxinfo | grep "OpenGL". You will see the full information about your GPU. Or use the command glxinfo | grep "OpenGL renderer" to display the model name of the GPU used. An example of the response:

Using Docker Container#

As You have successfully built and run GPU-accelerated Docker container you can do the following:

  1. Develop your project using UnigineEditor or run an application (Engine instance) via SDK Browser (version 2.0.13+).
  2. Run a UNIGINE-based application.
Last update: 2024-08-16
Build: ()