在Docker容器中运行基于UNIGINE的应用程序
You can run a UNIGINE-based application (whether it is a third-party solution or the one you've developed yourself) inside a Docker container you have already configured.您可以在已配置的Docker容器中运行基于UNIGINE的应用程序(无论是第三方解决方案还是您自己开发的解决方案)。
First, prepare the application that you want to run:首先,准备要运行的应用程序:
- Download it from an external resource or, if it is your application, create a final Release build.从外部资源下载它,或者,如果它是您的应用程序,请创建最终的发布版本。
-
Move the application with all its content and additional libraries (if any) to the Docker-related folder (unigine-in-docker):将应用程序及其所有内容和其他库(如果有)移动到Docker相关文件夹(unigine-in-docker):
$ mv cpp_samples/ ~/unigine-in-docker/ $ mv csharp_component_samples/ ~/unigine-in-docker/
Running C# and C++ UNIGINE-based applications slightly differs, so here as an example we use the C++ Samples and C# Component Samples demos included in UNIGINE SDK.运行基于C#和C++UNIGINE的应用程序略有不同,因此这里作为示例,我们使用UNIGINE SDK中包含的C++ Samples和C# Component Samples演示。
Running C++ Application运行C++应用程序#
-
Enable connections with the X-server:启用与X-server的连接:
$ xhost +local:*
-
Launch the C++ application:启动C++应用程序:
$ cd ~/unigine-in-docker/ $ docker run -it --rm \ --runtime=nvidia --gpus 0 \ -e NVIDIA_VISIBLE_DEVICES=0 \ -e DISPLAY=${DISPLAY} \ --device /dev/snd \ -e NVIDIA_DRIVER_CAPABILITIES=display,compute \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v `pwd`/cpp_samples:/opt/project \ -v /etc/localtime:/etc/localtime:ro \ -w /opt/project/bin/ \ run_unigine_in_docker:latest \ ./cpp_samples_x64
Running C# Application运行C#应用程序#
-
Enable connections with the X-server:启用与X-server的连接:
$ xhost +local:*
-
Launch the C# application:启动C#应用程序:
$ cd ~/unigine-in-docker/ $ docker run -it --rm \ --runtime=nvidia --gpus 0 \ -e NVIDIA_VISIBLE_DEVICES=0 \ -e DISPLAY=${DISPLAY} \ --device /dev/snd \ -e NVIDIA_DRIVER_CAPABILITIES=display,compute \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v `pwd`/csharp_component_samples:/opt/project \ -v /etc/localtime:/etc/localtime:ro \ -w /opt/project/bin/ \ run_unigine_in_docker:latest \ dotnet csharp_component_samples_x64.dll -console_command "world_load csharp_samples"
Congratulations! You have successfully run a UNIGINE-based application in a Docker container!恭喜您!您已经成功地在Docker容器中运行了一个基于unigine的应用程序!