Running the Unreal Editor from a Docker container
In order to run the Unreal Editor from within a Docker container, you will need the following:
Before you can start working with an Unreal Editor container, you will first need to build or pull a suitable container image. Voyage employees will be working with the Deepdrive Docker image, which is documented in the section Obtaining the Deepdrive Docker image.
To start a container from which the Unreal Editor can be run, open a terminal window in the directory containing your Unreal project's source code and execute the following command ($IMAGE_NAME should be replaced with the name of the Docker image that you obtained in Step 1):
docker run --rm -ti --runtime=nvidia --name=unreal_editor "-v$HOME/.config/Epic:/home/ue4/.config/Epic" -v`pwd`:/projectdir -w /projectdir -v/tmp/.X11-unix:/tmp/.X11-unix:rw -e DISPLAY -v/run/user/$UID/pulse:/run/user/1000/pulse $IMAGE_NAME bash
The meaning of each of the arguments to the
docker runcommand is as follows:
--rmensures the container will be deleted after it has finished running. This ensures you have a clean environment to work from each time you start the image. It is important to note that no data will be lost when the container is deleted, since the project source directory and the Unreal Editor's configuration directory are both bind-mounted from the host system's filesystem.
-tiruns the container in interactive mode, which allows you to run commands from the bash shell inside the container in much the same manner as you would on the host system.
--runtime=nvidiainstructs Docker to use the NVIDIA Docker runtime instead of the default Docker runtime. This allows the container to access the GPU resources of the host system.
--name=unreal_editorassigns the identifier "unreal_editor" to the container. This is useful if you need to run other Docker commands that manipulate or interact with the container while it is running.
-v$HOME/.config/Epic:/home/ue4/.config/Epicbind-mounts the host filesystem directory
~/.config/Epicinto the container. This directory is where the Unreal Editor stores its configuration data and compiled shader cache. Storing this data on the host filesystem allows the Unreal Editor to remember information from previous runs and ensures it behaves in a manner more consistent with running the Editor directly on the host system.
-v`pwd`:/projectdirbind-mounts the current working directory into the container. This allows the Unreal Editor to access your Unreal project's source code.
-w /projectdirsets the default working directory of the container to the directory containing your Unreal project's source code.
-v/tmp/.X11-unix:/tmp/.X11-unix:rwbind-mounts the host system's X11 socket into the container. This allows the Unreal Editor to create graphical windows that will be displayed on the host system.
-e DISPLAYpropagates the value of the
DISPLAYenvironment variable from the host system to the container. This is needed for correct X11 display behaviour.
-v/run/user/$UID/pulse:/run/user/1000/pulsebind-mounts the host system's PulseAudio socket into the container. This is only necessary if audio output is required.
$IMAGE_NAMEis a placeholder that should be replaced with the name of the Docker image that you obtained in Step 1.
bashstarts an interactive bash shell within the container.
Unless you are working with a Blueprint-only Unreal project, you will need to compile your project's C++ source code before you can run the Unreal Editor. You can do this by running the following command inside the container's interactive bash shell:
Once the source code for your Unreal project has been compiled, you can start the Unreal Editor by running the following command inside the container's interactive bash shell:
If everything is working correctly, you should see the Unreal Editor splash screen appear while the Editor is loading, followed by the window for the Editor itself.
If you would like to run additional commands inside the container while the Unreal Editor is running, you can attach additional interactive bash shells to the container by running the following command:
docker exec -ti unreal_editor bash
This command can be run multiple times to attach multiple interactive shells. It is important to note that all additional interactive shells will be terminated when the container is stopped, which happens the moment that the original bash shell (the one created when the container was started) exits. Closing any of the additional attached shells will not stop the container.
Once you have closed the Unreal Editor and returned to the container's interactive bash shell, you can stop the container by simply closing the bash shell:
Note that this will also terminate any additional interactive shells that you may have attached to the container while it was running.
Because the Docker image for Deepdrive contains CUDA 10.0, the version number of the NVIDIA GPU driver matters. You will need to ensure you have a version of the NVIDIA GPU driver compatible with CUDA 10.
Before you can pull the Docker image for Deepdrive, you will need to login to Docker Hub:
# This will prompt for your Docker ID and password
Once you have authenticated, the Docker image for Deepdrive can then be pulled by executing the following command:
docker pull deepdriveio/ue4-deepdrive-deps:latest
If you intend to run the Deepdrive deep learning agents inside the container, you will need to bind-mount the directory containing the Deepdrive source code in addition to the source code for the Deepdrive simulator Unreal project:
# These are the original arguments specified in Step 2:
-v`pwd`:/projectdir -w /projectdir
# Replace them with these arguments:
-v`pwd`:/simdir -w /simdir -v/path/to/deepdrive:/deepdrivedir
/path/to/deepdrivewith the appropriate host filesystem path for the directory containing the Deepdrive source code.