The docker container and the host machine can share directories, allowing you to bring your experiments home. This post is a continuation of this one, where we computed our first example with Xlab.

  1. Make an Xlab directory and go to it:
mkdir xlab
cd xlab/
  1. We want to take a picture of a surface using XLab and bring it on the host machine, outside the container. So make a directory for sharing files between the host and the container:
mkdir shared
  1. Open acces to X:
xhost +local:
  1. Run an Xlab container with the shared directory mounted. You should replace ABSOLUTE-PATH-TO-SHARED by the absolute path to the shared directory of step 2.
docker run -it --rm \
--volume=/tmp/.X11-unix:/tmp/.X11-unix \
--device=/dev/dri/card0:/dev/dri/card0 \
--env "DISPLAY=$DISPLAY" \
--network="host" \
--volume=ABSOLUTE-PATH-TO-SHARED:/shared xlab
  1. Compute an example (as explained in the previous post).

  2. Find your favorite point of view with the mouse in the XLab | Viewer window. You can use the Space key to center the view and the “o” key to go back to the default view. Fullscreen with “f”, switch viewers with “r”.

  3. In the XLab window, right click on the node called “ViewerR3” and select “Open”. Maximize your window if necessary. Click on the “Scene” node. Expand the left-hand panel if necessary to select “Controls”. Then click on the button right beside “Screenshot”. Write

/shared/my-picture.png

and press Enter. Close the XLab windows and exit the container. Don’t forget to close access to X with

xhost -local:
  1. Open shared/my-picture.png. Congratulations, you brought your picture home. Now you can save your experiments.