Ask Your Question
0

Sagemath in Docker cannot access host files

asked 2025-08-03 19:40:21 +0200

I spent the last day trying to compile sagemath from sources on Fedora 42 KDE. I don't want to list all the problems I had. At the end it "almost" worked, but plot do not seem to work.

Then I tried with Docker, that is much more simple, the only drawback is that from the container I cannot access host files. I know I can tell the "docker run" command to mount a host directory, but the only place I found more or less convenient is /mnt, but then I have permissions problems. Also, I can build a new image on top of the given one, in which make some modification, for example the creation of a directory under the home, but I don't know well Docker, so I would like to ear the suggestions of people more expert than me.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2025-08-03 22:58:17 +0200

Given that I use Fedora, that in turn use SELinux, there was a change of security context to do on the host file under the host dir, before running for the first time the container with the mount

chcon -Rt svirt_sandbox_file_t ~/host/dir

Then, the following script, run as root, do the job

#!/bin/bash

docker run \
    -p8888:8888 \
    --name sagemath \
    -v ~/host/dir:/home/sage/sage/build \
    sagemath/sagemath:latest sage-jupyter
docker stop sagemath
docker rm sagemath

Only the first time it is run, it download the sagemath Docker image file.
You have to exit from within Jupyter with Shutdown.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2025-08-03 19:40:21 +0200

Seen: 8,691 times

Last updated: Aug 03