Compose cannot start the service: exec "python manage.py runserver" failed
Cannot start service api: OCI runtime create failedShort answer
The container runtime was asked to run a program literally named 'python manage.py runserver', including the spaces. That happens when a whole command is placed in one list item, or in a Dockerfile exec form. Give each word as its own item, or write the command as a plain string in Compose.
Fix it fast
1Find out which cause you have
Print how Compose resolved the command and entrypoint of the failing service.
docker compose config | grep -nE 'command|entrypoint'2Match what you see, then jump to its fix
What does the error look like?
Cannot start service api: OCI runtime create failedstarting container process caused: exec: "python manage.py runserver
Cause 1 of 2
The whole command sits in one item of a list or JSON array
1Check
The exec form is parsed as a JSON array and starts the first item as the executable. If the array has one item with spaces in it, the runtime looks for a program with that exact name.
grep -nE 'CMD|ENTRYPOINT|command' Dockerfile docker-compose.yml2Fix
Split the command so each word is a separate quoted item, using double quotes in a Dockerfile, or write it as a string in Compose.
# Dockerfile
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
# docker-compose.yml
command: python manage.py runserver 0.0.0.0:80003Verify
The service starts and stays up.
docker compose up -d --build api
docker compose ps apiConfirmed by docs.docker.com
Cause 2 of 2
The command needs a shell, but none is used
1Check
The Compose docs say the command field is not run inside the image's shell automatically, so shell features need an explicit shell call.
docker compose config | grep -n command2Fix
Call the shell yourself, so that it handles the operators and variables.
command: ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]3Verify
Both steps run, in order, in the logs.
docker compose logs api --tail 30Confirmed by docs.docker.com
How do I stop it coming back?
- Use double quotes in Dockerfile JSON arrays, one word per item.
- Read the resolved config with docker compose config before running a changed file.
- Move multi-step start commands into a small entrypoint script.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
Related fixes
Servers
Docker cannot find manage.py or Permission denied on '/manage.py'
PermissionError: [Errno 13] Permission denied: '/manage.py'
The container is looking for manage.py in a directory where the file is not.
3 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
pip install cryptography tries to compile and fails in a Docker build
fatal error: 'openssl/aes.h' file not found
cryptography ships prebuilt wheels.
3 causes, each with a fixServers
Docker build fails with apk: not found in a Python or Ubuntu image
/bin/sh: 1: apk: not found
apk is the package manager of Alpine Linux only.
2 causes, each with a fixServers
docker logs prints nothing for a Flask or Python container
the output appears only after the app exits, or in large delayed bursts
docker logs only shows what the process writes to standard output and standard error.
2 causes, each with a fixServers
Docker build or container cannot create a directory: permission denied
PermissionError: [Errno 13] Permission denied: '/app/output.csv'
Once USER switches to a non-root account, every later RUN and the container itself run as that account.
3 causes, each with a fix