Scenario: Customer want to have Licensing server in docker for simplify of update/upgrade process and simplify license update process.
Solution: Custom-build Docker container.
Solution.
Create dirs for project
mkdir /opt/lic_matlab && mkdir /opt/lic_matlab/license && mkdir /opt/lic_matlab/files && cd /opt/lic_matlab
Replace license file with correct one: /opt/lic_matlab/license/license.dat
Create shell-script to control docker and other files:
touch /opt/lic_matlab/control_lic.sh
touch /opt/lic_matlab/docker-commpose.yml
touch /opt/lic_matlab/Dockerfile
chmod +x /opt/lic_matlab/control_lic.sh
content of control_lic.sh
#!/bin/bash
case "$1" in
start)
docker compose -f /opt/lic_matlab/docker-compose.yml up -d
;;
stop)
docker compose -f /opt/lic_matlab/docker-compose.yml down
;;
restart)
docker compose -f /opt/lic_matlab/docker-compose.yml down
docker compose -f /opt/lic_matlab/docker-compose.yml up -d
;;
*)
echo "Usage: ./control_lic.sh {start|stop|restart}"
exit 1
;;
esac
Content of docker-compose.yml
services:
lic-server:
image: matlab-lic-server:latest
restart: unless-stopped
hostname: "lic.your-domain.ca"
volumes:
- ./license/license.dat:/etc/lmgrd/licenses/license.dat
- ./var/log/lic_matlab/:/opt/logs/
ports:
- "9010:9010"
- "9011:9011"
networks:
inside:
mac_address: 00:00:00:00:00:00
# replace MAC with correct one
networks:
inside:
external: false
ipam:
config:
- subnet: 10.100.10.0/24
content of Dockerfile
FROM rockylinux:8.5
# add the flexlm commands to /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/lmgrd/etc/glnxa64"
COPY /files /usr/local/bin
RUN yum update -y && yum install wget unzip -y && mkdir /lmgrd \
&& cd /lmgrd && wget https://ssd.mathworks.com/supportfiles/downloads/R2024b/license_manager/R2024b/daemons/glnxa64/mathworks_network_license_manager_glnxa64.zip \
&& unzip mathworks_network_license_manager_glnxa64.zip \
&& rm -vf mathworks_network_license_manager_glnxa64.zip \
&& mkdir /opt/logs && mkdir /etc/lmgrd && mkdir /etc/lmgrd/licenses
## Set timezone to Regina
RUN yum install -y tzdata && yum clean all
RUN ln -sf /usr/share/zoneinfo/America/Regina /etc/localtime
VOLUME /etc/lmgrd/licenses
VOLUME /usr/tmp
ENV LM_LICENSE_FILE=/etc/lmgrd/licenses/license.dat
ENV LMGRD_PORT=9010
ENV MLM_PORT=9011
EXPOSE $LMGRD_PORT
EXPOSE $MLM_PORT
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
content of files/entrypoint.sh
#!/bin/bash
set -e
echo ""
# to help users determine their LMHostID
lmutil lmhostid
echo ""
echo "look at ./logs/log.log for more details"
echo ""
# forward all command line arguments to lmgrd
# NOTE: lmgrd -z flag is required to 'Run in foreground.' so that
# Docker will not start sleeping regardless flags.
lmgrd -z >> /opt/logs/log.log 2>&1
Build container with:
docker build --tag matlab-lic-server .
Start container with:
/opt/lic_matlab/control_lic.sh start
License update porocess:
1. backup.
2. Replace license file with new one here: /opt/lic_matlab/license/license.dat
3. restart container with: /opt/lic_matlab/control_lic.sh restart
update/upgrade license server:
Locate official page to download new license server release. Example: https://www.mathworks.com/support/install/license_manager_files.html?s_tid=srchtitle_site_search_2_download%20license%20server
Copy direct link to new license server release. Example: https://ssd.mathworks.com/supportfiles/downloads/R2024b/license_manager/R2024b/daemons/glnxa64/mathworks_network_license_manager_glnxa64.zip
Edit Dockerfile and replace link to new license server (locate command wget and replace argument with new link).
Rebuild container with:
docker build --tag matlab-lic-server .
Watch for errors in output.
Restart container with:
/opt/lic_matlab/control_lic.sh restart
done.