First, run the container using the following docker run command:
docker run --rm -it <image_name> matlab -licmode onlinelicensing
When the container runs, it will ask you for your MathWorks Account login information. You may additionally be prompted to select a license. Once you've signed in with your MathWorks Account and MATLAB is ready for a command, open a new terminal window. In this new terminal, run the following docker commit command to save the changes to the container:
docker commit <container_id> <new_image_name>
This will save the container as a new image named <new_image_name> with the MATLAB (Individual) licensing enabled. The container id can be obtained by running docker ps.
When you run this new container, you will not be requested to log in, and MATLAB will just launch. Note that we have committed the entrypoint changes to the container as well, so MATLAB will always launch with the -licmode onlinelicensing parameter unless specified otherwise in the docker run command. If you need to modify the entrypoint, ensure MATLAB is launched with the -licmode onlinelicensing parameter to ensure the MATLAB (Individual) licensing is used.