I am trying to run a task using a custom activity on Azure Batch. My custom activity looks like the following (edited for brevity):
"typeProperties": {
"command": "/bin/bash -c \"run.sh\"\n",
...
"userIdentity": {
"autoUser": {
"scope": "pool",
"elevationLevel": "admin"
}
}
}
My run.sh script simply contains:
docker run hello-world
When I run this I get the following error in stderr.txt:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.37/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
I thought running as admin might get me access to the socket required to run docker however this does not seem to be the case. How can I run docker commands as an Azure Batch command without permission errors?
P.S. I would like a solution that can be done from the portal ideally by editing config JSON
Thanks for the help!
In the Azure portal, when you finish all the preparation before creating the task, such as pools, jobs, etc. Then you can create the tasks to do what you want.
For your issue, when you create the task, the screenshot like below:
If you choose the User identity with Pool autouser, Admin, then you will get success. And the output will like below:
But if you choose others, you will get the error as you posted and the output like below:
I just test the Batch task in the Azure portal. Hope this will help you.