-
Notifications
You must be signed in to change notification settings - Fork 2
Matlab on Docker and EC2
Here is an account of how I installed Matlab inside a Docker container running in an Amazon EC2 instance.
If you wish to do the same, please make your own arrangements with Mathworks and licensing.
The process was not as linear as it looks here. But I think the steps below are pretty accurate.
I used:
- ubuntu
- t2.micro
- 100GB storage
- allow all TCP, but only from my workstation IP
- Brainard Lab "render-toolbox" keypair
The instance IP happened to be 54.68.1.92
, which appears below.
ssh -i render-tooblox.pem ubuntu@54.68.1.92
sudo apt-get update
sudo apt-get -y install linux-image-extra-$(uname -r)
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get -y install lxc-docker
sudo docker info
You should see Storage Driver: aufs
.
Thanks to Roberto Hashioka
sudo docker build -t ninjaben/docker-desktop git://github.com/rogaha/docker-desktop.git
sudo docker images
You should see ninjaben/docker-desktop
CONTAINER_ID=$(sudo docker run --mac-address=e4:ce:8f:60:8f:0a -d -P ninjaben/docker-desktop)
echo $CONTAINER_ID
It was d38c012e46045cd3ff8b05033e2362a842c0f94b94e247e55760618a3e1989a1
.
echo $(sudo docker logs $CONTAINER_ID | sed -n 1p)
It was oeShoh2eis6j
.
sudo docker port $CONTAINER_ID 22
It was 32768
.
First you should download the installer and license file to your workstation.
I have a license for host id e4:ce:8f:60:8f:0a
, which appears below.
scp -P 32768 ~/Downloads/matlab_R2015a_glnxa64.zip docker@54.68.1.92:/home/docker/matlab_R2015a_glnxa64.zip
scp -P 32768 ~/Downloads/license.lic docker@54.68.1.92:/home/docker/license.lic
ssh -Y docker@54.68.1.92 -p 32768
sudo apt-get install gedit
gedit
Should get a gedit window on your workstation (ignore warnings, wait several seconds)
sudo df -h
Should show about 77GB free space on rootfs
.
I did the interactive install. I think a "silent" install would also be possible but I didn't work that out.
cd /home/docker
unzip matlab_R2015a_glnxa64.zip -d /home/docker/matlab-installer
cd matlab-installer
sudo ./install
I used:
- 'dhb' account
- designated computer license
- default install folder
- all products
- yes, symbolic links
- let 'er rip!
Upon completion:
- Don't activate yet (for some reason an option we need will be missing).
sudo matlab
- Should prompt for activation (with additional options).
- Activate manually with
/home/docker/license.lic
. - Try playing Matlab.
- 'matlab -nodesktop -nosplash -r "eye(42),quit"'
So now Matlab is installed in a Docker container. Commit a Docker image so we can reuse this. Also push the image to Docker Hub so we can reuse this from anywhere. Use a private Docker Hub repo because Matlab is non-free.
sudo docker commit $CONTAINER_ID ninjaben/matlab:activated
sudo docker push ninjaben/matlab:activated
After several minutes, the docker commit
worked for me.
After many minutes, the docker push
seemed to finish uploading. But then it failed at the last minute with an error much like this one. Alas!
The image is large, about 12GB, and most of that is in one Docker "layer". I think this contributes to the error.
Even if the docker push
fails, we still have a useful Docker image stored locally in our EC2 instance. We can save this progress in an AMI.
Save an AMI of this EC2 instance for reuse. Then terminate this EC2 instance to avoid ongoing billing.
Later, we should be able to launch a new instance based on this AMI. Then we can ssh in and launch the Docker container with:
sudo docker run -t -i ninjaben/matlab:activated "/bin/bash"