title: docker-compose: run rails db:setup and rake tasks to init data
body: <p>I can't find the way to execute the following commands from a <code>docker-compose.yml</code> file:</p>
  
  <ul>
  <li><code>rails db:setup</code></li>
  <li><code>rails db:init_data</code>.</li>
  </ul>
  
  <p>I tried to do that as follows and it failed:</p>
  
  <pre><code>version: '3'
  
  services:
    web:
      build: .
      links:
        - database
        - redis
      ports:
        - "3000:3000"
      volumes:
        - .:/usr/src/app
      env_file:
        - .env/development/database
        - .env/development/web
      command: ["rails", "db:setup"]
      command: ["rails", "db:init_data"]
    redis:
      image: redis
    database:
      image: postgres
      env_file:
        - .env/development/database
      volumes:
        - db-data:/var/lib/postgresql/data
  volumes:
    db-data:
  </code></pre>
  
  <p>Any idea on what's going wrong here ? Thank you.
  The code source is on the <a href="https://github.com/belgoros/myapp" rel="nofollow noreferrer">GitHub</a>.</p>