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.
docker execcommand. (It doesn't work for the same reason that running"python manage.py ..."with quotes from your local shell doesn't work, it forces the system to consider the whole thing as one "word".)