{"id":29111648,"url":"https://github.com/erroneousboat/docker-django","last_synced_at":"2025-06-29T10:02:01.082Z","repository":{"id":26568837,"uuid":"30022971","full_name":"jpbruinsslot/docker-django","owner":"jpbruinsslot","description":"A project to get you started with Docker and Django.","archived":true,"fork":false,"pushed_at":"2018-12-15T10:58:21.000Z","size":896,"stargazers_count":180,"open_issues_count":0,"forks_count":61,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-28T01:01:57.231Z","etag":null,"topics":["django","docker","nginx","postgresql","uwsgi"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpbruinsslot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-29T14:12:50.000Z","updated_at":"2025-02-19T18:22:10.000Z","dependencies_parsed_at":"2022-08-31T21:33:57.983Z","dependency_job_id":null,"html_url":"https://github.com/jpbruinsslot/docker-django","commit_stats":null,"previous_names":["erroneousboat/docker-django"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jpbruinsslot/docker-django","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbruinsslot%2Fdocker-django","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbruinsslot%2Fdocker-django/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbruinsslot%2Fdocker-django/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbruinsslot%2Fdocker-django/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpbruinsslot","download_url":"https://codeload.github.com/jpbruinsslot/docker-django/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbruinsslot%2Fdocker-django/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262574128,"owners_count":23330777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","docker","nginx","postgresql","uwsgi"],"created_at":"2025-06-29T10:01:36.496Z","updated_at":"2025-06-29T10:02:01.045Z","avatar_url":"https://github.com/jpbruinsslot.png","language":"Python","funding_links":[],"categories":["Projects","Boilerplate"],"sub_categories":["Boilerplate","Docker Tutorials"],"readme":"Docker Django\n=============\n\n## tl;dr\n```bash\n$ git clone git@github.com:erroneousboat/docker-django.git\n$ docker-compose up\n```\n\nNow you can access the application at \u003chttps://localhost\u003e and the admin site\nat \u003chttps://localhost/admin\u003e.\n\nA project to get you started with Docker and Django. This is made to\nserve as an example for you to hack on, so I don't claim that this is the\ncorrect way to setup a system with Django and Docker. Thus, I advice to also\nlook at other projects.\n\nStack and version numbers used:\n\n| Name           | Version  |\n|----------------|----------|\n| Django         | 2.1.4    |\n| Nginx          | 1.15     |\n| Postgresql     | 11.1     |\n| uWSGI          | 2.0.17.1 |\n\n## Folder structure\n\n```\n$ tree -L 1 --dirsfirst\n.\n├── config              # files needed for configuration\n├── webapp              # actual webapp\n├── docker-compose.yml  # docker-compose setup with container orchestration instructions\n├── LICENSE             # license for this project\n└── README.md           # this file\n```\n\n## Setting up\n\n### Docker\nSee installation instructions at: [docker documentation](https://docs.docker.com/install/)\n### Docker Compose\nInstall [docker compose](https://github.com/docker/compose), see installation\ninstructions at [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)\n\n### Django\nCreate django project in the `webapp` folder or copy a project to the `webapp`\nfolder or use the sample project enclosed in this project and go directly to\nthe section 'Fire it up':\n\n```bash\n# Be sure you have Django installed on your system\n$ django-admin startproject \u003cname_project\u003e\n```\n\nEdit `config/environment/development.env` file and add the name of your\nproject at `DJANGO_PROJECT_NAME` or just leave it as is to start the default\napplication.\n\n\nEdit the `settings.py` file with the correct database credentials and static\nroot:\n\n```python\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.postgresql_psycopg2',\n        'NAME': os.environ.get('POSTGRES_NAME'),\n        'USER': os.environ.get('POSTGRES_USER'),\n        'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),\n        'HOST': os.environ.get('POSTGRES_HOST'),\n        'PORT': os.environ.get('POSTGRES_PORT'),\n    }\n}\n\nSTATIC_ROOT = '/srv/static-files'\n```\n\n### Environment variables\nThe file `config/environment/development.env` contains the environment\nvariables needed in the containers. You can edit this as you see fit, and at\nthe moment these are the defaults that this project uses. However when you\nintend to use this, keep in mind that you should keep this file out of version\ncontrol as it can hold sensitive information regarding your project. The file\nitself will contain some commentary on how a variable will be used in the\ncontainer.\n\n## Fire it up\nStart the container by issuing one of the following commands:\n```bash\n$ docker-compose up             # run in foreground\n$ docker-compose up -d          # run in background\n```\n\n## Other commands\nBuild images:\n```bash\n$ docker-compose build\n$ docker-compose build --no-cache       # build without cache\n```\n\nSee processes:\n```bash\n$ docker-compose ps                 # docker-compose processes\n$ docker ps -a                      # docker processes (sometimes needed)\n$ docker stats [container name]     # see live docker container metrics\n```\n\nSee logs:\n```bash\n# See logs of all services\n$ docker-compose logs\n\n# See logs of a specific service\n$ docker-compose logs -f [service_name]\n```\n\nRun commands in container:\n```bash\n# Name of service is the name you gave it in the docker-compose.yml\n$ docker-compose run [service_name] /bin/bash\n$ docker-compose run [service_name] python /srv/starter/manage.py shell\n$ docker-compose run [service_name] env\n```\n\nRemove all docker containers:\n```bash\ndocker rm $(docker ps -a -q)\n```\n\nRemove all docker images:\n```bash\ndocker rmi $(docker images -q)\n```\n\n### Some commands for managing the webapp\nTo initiate a command in an existing running container use the `docker exec`\ncommand.\n\n```bash\n# Find container_name by using docker-compose ps\n\n# restart uwsgi in a running container.\n$ docker exec [container_name] touch /etc/uwsgi/reload-uwsgi.ini\n\n# create migration file for an app\n$ docker exec -it [container-name] \\\n    python /srv/[project-name]/manage.py makemigrations scheduler\n\n# migrate\n$ docker exec -it [container-name] \\\n    python3 /srv/[project-name]/manage.py migrate\n\n# get sql contents of a migration\n$ docker exec -it [container-name] \\\n    python3 /srv/[project-name]/manage.py sqlmigrate [appname] 0001\n\n# get to interactive console\n$ docker exec -it [container-name] \\\n    python3 /srv/[project-name]/manage.py shell\n\n# testing\ndocker exec [container-name] \\\n    python3 /srv/[project-name]/manage.py test\n```\n\n## Troubleshooting\nQ: I get the following error message when using the docker command:\n\n```\nFATA[0000] Get http:///var/run/docker.sock/v1.16/containers/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS? \n\n```\n\nA: Add yourself (user) to the docker group, remember to re-log after!\n\n```bash\n$ usermod -a -G docker \u003cyour_username\u003e\n$ service docker restart\n```\n\nQ: Changes in my code are not being updated despite using volumes.\n\nA: Remember to restart uWSGI for the changes to take effect.\n\n```bash\n# Find container_name by using docker-compose ps\n$ docker exec [container_name] touch /etc/uwsgi/reload-uwsgi.ini\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferroneousboat%2Fdocker-django","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferroneousboat%2Fdocker-django","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferroneousboat%2Fdocker-django/lists"}