To run GUI applications (e.g. Python with interactive plotting) in docker, first create a non-root user in the docker image.The image/container user name should be the same as the $USER that will run the container on the host machine. The uid/gidof the user in container should also be identical to the one on the host; otherwise usermod and groupmod commands areneeded to alter them.

Refer to python/2.7/Makefile for building an image "python" with a regular user.

Next give only containers of $USER permission to access the X11 socket on the local host machine, and run a container withmounted X11 socket and explicitly specified user name.

The run-time -u or --user option can be skipped if the image's Dockerfile already sets a user name using USER.

To run a password-protected notebook in daemon mode, use the following command. To allow public access to this notebook, remove theloopback IP (127.0.0.1:) from the run command. Local-only access is preferred for safety.