Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Network Named License in Container #132

Open
Nerolf05 opened this issue Dec 10, 2024 · 1 comment
Open

Use Network Named License in Container #132

Nerolf05 opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
development-in-progress question Further information is requested

Comments

@Nerolf05
Copy link

Hi together, this is a follow on question to #77

Is there an update on that issue how to use a network named license within a container?
I am also trying to use a network named license within a custom Dockerfile on wsl-docker:

# Copyright 2023-2024 The MathWorks, Inc.
ARG MATLAB_RELEASE=R2023b 
ARG MATLAB_INSTALL_LOCATION="/opt/matlab"
ARG ADDITIONAL_PRODUCTS="Statistics_and_Machine_Learning_Toolbox MATLAB_Coder MATLAB_Compiler"
FROM mathworks/matlab:$MATLAB_RELEASE
ARG MATLAB_RELEASE
ARG ADDITIONAL_PRODUCTS
ARG MATLAB_INSTALL_LOCATION

ARG USER_NAME="user_a"
ARG USER_UID=1000
ARG USER_GID=1000
USER root

# Install mpm dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
    && apt-get update \
    && apt-get install --no-install-recommends --yes \
        wget \
        ca-certificates \
    && apt-get install -y git \
    && apt-get clean \
    && apt-get autoremove \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /tmp
USER matlab
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \
    && chmod +x mpm \
    && EXISTING_MATLAB_LOCATION=$(dirname $(dirname $(readlink -f $(which matlab)))) \
    && sudo HOME=${HOME} ./mpm install \
        --destination=${EXISTING_MATLAB_LOCATION} \
        --release=${MATLAB_RELEASE} \
        --products ${ADDITIONAL_PRODUCTS} \
    || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \
    && sudo rm -rf mpm /tmp/mathworks_root.log

COPY net.lic ${MATLAB_INSTALL_LOCATION}/licenses/
ENV MW_DDUX_FORCE_ENABLE=true MW_CONTEXT_TAGS=$MW_CONTEXT_TAGS,MATLAB:TOOLBOXES:DOCKERFILE:V1

USER root
RUN adduser --shell /bin/bash --disabled-password --gecos "" ${USER_NAME} \
    && echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER_NAME} \
    && chmod 0440 /etc/sudoers.d/${USER_NAME}

USER ${USER_NAME}
WORKDIR /home/${USER_NAME}

It builds fine. However when running i receive the following error:

/bin/run.sh: 241: cd: can't cd to /home/user_a/Documents/MATLAB/

Also when trying as explained in Create a Custom MATLAB Container:

docker run -it -rm -u user_a -e [email protected] mathworks/matlab:r2023b -batch "ver"
docker: Error response from daemon: unable to find user user_a: no matching entries in passwd file.

It seems like i am missing some important point.
Every help appreciated
Best

@michaelmcdonnellmw michaelmcdonnellmw self-assigned this Dec 10, 2024
@prabhakk-mw prabhakk-mw added question Further information is requested development-in-progress labels Dec 12, 2024
@Nerolf05
Copy link
Author

I was able to solve my problems, it was a license activation problem.
Since i am using two licenses, one individual for licensing Matlab, and one network named license for licensing selected toolboxes, the hierarchy of passing them was important:

docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v ./license.lic:/licenses/license.lic -e MLM_LICENSE_FILE=/licenses/license.lic:[email protected] --entrypoint bash dockerImageName

Here i am mounting the host's docker.sock for accessing docker within the container as i need to call compiler.package.docker. But i am not sure, if that's the best way to access docker in docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development-in-progress question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants