Answers: <p>This is most likely a problem with the django configuration better fitting to stackoverflow, and not so much a devops problem.</p>
  
  <p>Check the <code>settings.py</code> for the following entries:</p>
  
  <pre><code>INSTALLED_APPS = [
      (...)
      'django.contrib.staticfiles',
  ]
  </code></pre>
  
  <p>At the end of this file</p>
  
  <pre><code>STATIC_ROOT='staticfiles'
  STATIC_URL = '/static/'
  STATICFILES_DIRS = [
       os.path.join(BASE_DIR, 'static'),
  ]
  </code></pre>
  
  <p>source <strong>Django manual:</strong> <a href="https://docs.djangoproject.com/en/2.0/howto/static-files/" rel="nofollow noreferrer">How to static-files</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-23T14:17:25.577Z
Answers: 2018-08-23T14:17:25.577Z
Answers: Michael D.
Body: <p>I'm completely new to Docker and Django and I'm having trouble getting my Docker app to serve inside Django. Currently, I'm running my docker container with this command:</p>
  
  <pre><code>docker run -it --name web -p 8000:8000 --link mysql:db -v ~/directory:/app django
  </code></pre>
  
  <p>where <code>mysql</code> and <code>django</code> refer to containers defined earlier.</p>
  
  <p>Next, I'm using <code>manage.py</code> to make migrations and migrate, then serving with the following command:</p>
  
  <pre><code>mod_wsgi-express start-server --reload-on-changes --working-directory /app/voting_project /app/voting_project/voting_project/wsgi.py &amp;
  </code></pre>
  
  <p>When I visit <code>localhost:8000</code> in my browser, it successfully renders the HTML template, but the CSS and images which I see locally are missing.</p>
  
  <p>The following errors are logged in the console:
  <a href="https://i.sstatic.net/kHAoq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kHAoq.png" alt="enter image description here"></a></p>
  
  <p>I've played with the structure of my directories a bit, but I can't seem to get the browser to find anything in <code>localhost:8000/static</code> or <code>localhost:8000/images</code>.</p>
  
  <p>I'm assuming 8000 is mapping to somewhere weird in my local directories, but I realize this could also be caused by a number of other things. Please let me know if I'm making any obvious mistakes.</p>
  
  <p>Thanks so much!</p>
  
Tags: <docker>
Title: Docker & Django - what directory does localhost point to?
UserDisplayName: Tom
ThreadText: # Docker & Django - what directory does localhost point to?
  
  (Asked by: username_0 on 2018-03-26)
  
  I'm completely new to Docker and Django and I'm having trouble getting my Docker app to serve inside Django. Currently, I'm running my docker container with this command:
  
  ```
  docker run -it --name web -p 8000:8000 --link mysql:db -v ~/directory:/app django
  
  ```
  
  where `mysql` and `django` refer to containers defined earlier.
  
  Next, I'm using `manage.py` to make migrations and migrate, then serving with the following command:
  
  ```
  mod_wsgi-express start-server --reload-on-changes --working-directory /app/voting_project /app/voting_project/voting_project/wsgi.py &
  
  ```
  
  When I visit `localhost:8000` in my browser, it successfully renders the HTML template, but the CSS and images which I see locally are missing.
  
  The following errors are logged in the console:
  [![enter image description here](https://i.sstatic.net/kHAoq.png)](https://i.sstatic.net/kHAoq.png)
  
  I've played with the structure of my directories a bit, but I can't seem to get the browser to find anything in `localhost:8000/static` or `localhost:8000/images`.
  
  I'm assuming 8000 is mapping to somewhere weird in my local directories, but I realize this could also be caused by a number of other things. Please let me know if I'm making any obvious mistakes.
  
  Thanks so much!
  
  **Tags:** docker
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-23. Score: 1
  
  This is most likely a problem with the django configuration better fitting to stackoverflow, and not so much a devops problem.
  
  Check the `settings.py` for the following entries:
  
  ```
  INSTALLED_APPS = [
      (...)
      'django.contrib.staticfiles',
  ]
  
  ```
  
  At the end of this file
  
  ```
  STATIC_ROOT='staticfiles'
  STATIC_URL = '/static/'
  STATICFILES_DIRS = [
       os.path.join(BASE_DIR, 'static'),
  ]
  
  ```
  
  source **Django manual:** [How to static-files](https://docs.djangoproject.com/en/2.0/howto/static-files/)
  
  
  ---
  
  