Skip to content

Change id of local matlab user for permissions #124

Open
@arunoruto

Description

@arunoruto

I am currently implementing a small bash script, which would launch an individual Matlab instance per user via Docker. Here is my current progress, and I can launch it for all three "versions" (X11, browser, VNC):

#!/usr/bin/env bash

IMAGE="mathworks/matlab"
VERSION="r2024b"
LICENCE="<path to licence file>"

SHM_SIZE="512M"

COMMAND_END=""
COMMAND_PARAM="-e DISPLAY=${DISPLAY} -v /tmp/.X11-unix:/tmp/.X11-unix:ro"
if [ -z "${1}" ]; then
  xhost +
else
  case $1 in
    "browser")
    COMMAND_PARAM='-p 8888:8888'
    COMMAND_END='-browser'
    ;;

    "vnc")
    COMMAND_PARAM='-p 5901:5901 -p 6080:6080'
    COMMAND_END='-vnc'
    ;;

    *)
    echo "'${1}' is not a valid flag. Please use 'browser' or 'vnc' for the respective protocoll or nothing for X11"
    exit 1
    ;;
  esac
fi

eval 'docker run --init -it --rm \
  ${COMMAND_PARAM} \
  --user ${UID}:${GID} \
  -e MLM_LICENSE_FILE="/network.lic" \
  -v ${LICENCE}:/network.lic \
  -v ${HOME}:/home/matlab/workdir \
  --shm-size=${SHM_SIZE} \
  ${IMAGE}:${VERSION} \
  ${COMMAND_END}'

When running the script (with VNC), I get the following permission error:

/bin/run.sh: 51: cannot create //.bashrc: Permission denied

Is there a way to make these things available for any user/group ID? Or are there any security reasons for doing so?
It would be nice to change the user ID inside the container without building a new image per user :)

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions