Init Container doesn't use docker image

mark o'reilly 96 Reputation points
2021-03-13T10:30:42.707+00:00

I'm deploying a django app to azure container instances using a yaml file.
I have an init container using the my custom docker image hosted in acr to run database migrations before the rest of the containers are deployed.
The command the init container needs to run is very simple: python manage.py migrate, however I'm getting the following log message and the stack doesn't deploy:

container_linux.go:247: starting container process caused "exec: \"python manage.py migrate\": executable file not found in $PATH"

The thing is, when I run this image locally, or in another deployed container, I have no trouble running this command. In fact, previously before I had discovered init containers, I had a container in the main group that would run this command and then shut down, no problems.

I've also tried using the absolute path of python, which returned the following log message:

container_linux.go:247: starting container process caused "exec: \"/usr/local/bin/python manage.py migrate\": stat /usr/local/bin/python manage.py migrate: no such file or directory"
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
700 questions
0 comments No comments
{count} votes

Accepted answer
  1. mark o'reilly 96 Reputation points
    2021-03-13T10:51:29.58+00:00

    I needed to specify the command in exec form as per the docs:

    command: ["python", "manage.py", "migrate"]  
    

    The migrations ran successfully.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.