Docker and Django manage.py

I’m trying to find a workflow with Docker and Django. Currently, I’m using the basic configuration from the docker documentation.

I’d like to use manage.py startapp directly from the container to start a new app using:

  • Install cURL compiled with OpenSSL and zlib in Dockerfile
  • Can a variable be used in docker FROM?
  • How to scale a NodeJS stateful application
  • docker PHP-APACHE "You don't have permission to access / on this server”
  • How to delete untagged images from AWS ECR Container Registry
  • Can a docker process access programms on the host with ipc
  • docker-compose run web ./manage.py startapp myapp
    

    But all the files created in the volume are owned by the root user and not by myself, so I can’t edit them from the host.

    My idea is to avoid installing all the requirements on my host machine but maybe I should not create app from the container?

    One possible solution is to create a user and make it having the same UID/GID than my user on my host machine but it won’t work if I try to use an other account on my host machine…

    Any suggestion?

  • Docker complains that bind source path doesn't exist, but it DOES
  • Kubernetes for a Development Environment
  • Swift Perfect compile command failed for linux environment
  • Keep MySQL data inside Docker container
  • Docker Centos 7 easy_install supervisor ssl issue behind proxy
  • Docker Quickstart Terminal crash on Mac OS X
  • One Solution collect form web for “Docker and Django manage.py”

    What worked best for me was avoiding (or minimizing) file creation inside the containers.

    My Dockerfile would just copy the requirements.txt and install them;
    and the container would access the app files through a mounted volume.

    I pass the env var PYTHONDONTWRITEBYTECODE=1 to the containers, so python does not create *.pyc/*.pyo files.

    The few times I cannot avoid it (like, ./manage.py makemigrations), I run chown afterwards.
    It’s not ideal, but as this happens rarely for my case, I don’t bother.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.