5

I am running Ubuntu MATE 20.04 LTS. I have installed Docker to this system.
I need to run FreeMat 4.2 which is not available for Ubuntu 20.04 LTS anymore because of Qt4 deprecation.

I did the following:

sudo apt-get install docker.io
sudo usermod -a -G docker $USER
# reboot

mkdir ~/docker-freemat
cat > ~/docker-freemat/Dockerfile << EOF
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y freemat
CMD freemat
EOF

docker build -t ubuntu:freemat ~/docker-freemat

To run FreeMat from container I'm using the following command:

docker run -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --user="$(id --user):$(id --group)" ubuntu:freemat

But the FreeMat window is non-functional, instead it looks like:

FreeMat from Docker

and terminal output is the following

X Error: BadAccess (attempt to access private resource denied) 10
  Extension:    130 (MIT-SHM)
  Minor opcode: 1 (X_ShmAttach)
  Resource id:  0x14e
X Error: BadShmSeg (invalid shared segment parameter) 128
  Extension:    130 (MIT-SHM)
  Minor opcode: 5 (X_ShmCreatePixmap)
  Resource id:  0x3200014
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x3200015
...

How to get rid of this error and get application window shown normally and fully-functional?


Some notes:

  1. Changing 18.04 to 16.04 or even 14.04 in Dockerfile does not change anything
  2. Installing Docker from docker.com does not change anything
4
  • I think passing just the X11 socket to the docker container isn't enough. Errors indicate that the container cannot access shared memory which is resident in the host OS. If you want to run the aforementioned program in docker just because the unavailability of Qt4 , you can download and compile the Qt4 source code. Here is the instructions May 22, 2020 at 7:02
  • Also you have another choice. --ipc option for docker might help you to enable the container to communicate with the host processes ( e.g X-server ).But there are also security considerations . See here May 22, 2020 at 7:12
  • Also as stated here the MIT-SHM is actually an extension for passing the XImages and some Pixmaps via shared memory. So if the container cannot access that , you cannot open any graphical application. May 22, 2020 at 7:19
  • Great. @ParsaMousavi please transform your comments to the answer. Setting --ipc="host" make it work!!!
    – N0rbert
    May 22, 2020 at 7:37

1 Answer 1

9
+50

You can set the option --ipc=host to enable the docker container to communicate with host processes and also accessing the shared memories .

The command to launch graphical application will look as follows:

docker run --ipc=host -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --user="$(id --user):$(id --group)" ubuntu:freemat

and will show the application window:

FreeMat


MIT_SHM is actually an extension for passing the XImages and some Pixmaps via shared memory. So if the container cannot access that , you cannot open almost any graphical application.

And if you're concerned with the security , you can use --cap-drop to drop some capabilities as stated here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .