title: Run django migrate in docker
body: <p>I am building a Python+Django development environment using docker. I defined Dockerfile files and services in docker-compose.yml for web server (nginx) and database (postgres) containers and a container that will run our app using uwsgi. Since this is a dev environment, I am mounting the the app code from the host system, so I can easily edit it in my IDE.</p>
  
  <p>The question I have is where/how to run migrate command. </p>
  
  <p>In case you don't know Django, migrate command creates the database structure and later changes it as needed by the project. I have seen people run migrate as part of the compose command directive <code>command: python manage.py migrate &amp;&amp; uwsgi --ini app.ini</code>, but I do not want migrations to run on every container restart. I only want it to run once when I create the containers and never run again unless I rebuild.  </p>
  
  <p>Where/how would I do that?</p>
  
  <p>Edit: there is now an open issue with the compose team. With any luck, one time command containers will get supported by compose. <a href="https://github.com/docker/compose/issues/1896" rel="nofollow noreferrer">https://github.com/docker/compose/issues/1896</a></p>