Execute file permission for Azure Container Instances


Azure Container Instances (ACI) supports mounting a git repository as a volume. This is a nice way to get scripts and tools made available in a the docker container that you intend to run on ACI. Unfortunately when working on windows, file permissions is incompatible with linux file permissions, so when you create a shell script on a windows machine and commit it to git and expect it to have execute permissions inside your linux container on ACI, then you are out of luck.

Of course you can tell git which file permissions your shell should have, but I can never remember the commands for that, which is why I decided to finally add this information to my blog.

To see the current permission use
git ls-tree HEAD

The permissions are shown with the chmod nummeric syntax after the 100, thus 644 would be read+write for the owner but no execute. To change the permission to include execute run

git update-index --chmod=+x run.sh

Now you can commit the changes to git, and next time you mount the github project as a volume mount you will be able to execute the shell script.