Reputation: 367
I've got a Django server running nicely in a Docker container called loc-vol-web
.
When I try to run Django management commands straight from the host CLI, it just doesn't work:
>> docker exec -it loc-vol-web "python /app/src/manage.py migrate"
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"python /app/src/manage.py migrate\": stat python /app/src/manage.py migrate: no such file or directory": unknown
However, all of the following work fine:
>> docker exec -it loc-vol-web "python"
Python 3.7.6 (default, Jan 3 2020, 23:35:31)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>> docker exec -it loc-vol-web "/bin/bash"
some_user@ce1b1c2ac208:/app$ python /app/src/manage.py
Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[auth]
changepassword
createsuperuser
[contenttypes]
remove_stale_contenttypes
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
some_user@ce1b1c2ac208:/app$
I am not sure why I can't just run manage.py
.
Upvotes: 0
Views: 1193
Reputation: 241
The problem is the way you run docker:
docker exec -it loc-vol-web "python /app/src/manage.py migrate"
It is taking everything in double quotes as the command.
It should be run without double quotes:
docker exec -it loc-vol-web python /app/src/manage.py migrate
Upvotes: 1