0

My goal is to run a python script, which is passed to a docker container containing source code and dependencies. This is to be run using Azure container instances (ACI). On my home machine I can do this in docker (setting ENTRYPOINT or CMD to "python") with

docker run myimage "myscript.py"

provided I spin up the container from a directory containing myscript.py.

After some reading I thought a similar thing could be achieved on azure using az container create --command-line as indicated here. My container creation would be something like

az container create \
  --resource-group myResourceGroup \
  --name my-container \
  --image myimage:latest \
  --restart-policy Never \
  --command-line "python 'myscript.py'"

However the container is unable to find myscript.py. I am using the Azure Cloud Shell. I have tried spinning up the container from a directory containing myscript.py, and I have also tried adding a file share with myscript.py inside. In both cases I get the error

python3: can't open file 'myscript.py': [Errno 2] No such file or directory

I think I simply do not understand the containers and how they interact with the host directory structure on azure. Can anyone provide some suggestions or pointers to resources?

elltrain
  • 82
  • 4

1 Answers1

0

provided I spin up the container from a directory containing myscript.py.

From where you issue the command to start an container instance does not matter at all. The files need to be present inside your image. Or you can also mount storage into it and read from there.

silent
  • 14,494
  • 4
  • 46
  • 86
  • Thanks @silent! This was the nudge I apparently needed to understand the `--azure-file-volume-mount-path` option. I was successful when adding `--azure-file-volume-mount-path /mnt` (along with the other azure-file-volume flags) and ` --command-line "python /mnt/myscript.py"` to the container create command. – elltrain Feb 21 '20 at 16:17