0

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.

2
  • 1
    Take out the quotes in your docker exec command. (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".) Commented Feb 13, 2020 at 12:03
  • @david-maze, you're a star!!! It works fine without the quotes... :face_palm: Commented Feb 13, 2020 at 12:05

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Jeeez... :face_palm: this is me being really stupid... Thanks for the answer, I can confirm it works fine without quotes...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.