title: Run sequelize migrates in docker compose
body: <p>I am trying to up two containers with node and postgres (i need to save the content of the database). Follow the code below:</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM node:lts-alpine
  
  RUN mkdir -p /home/node/api/node_modules &amp;&amp; chown -R node:node /home
  
  WORKDIR /home/node/api
  
  COPY package.json /
  
  USER node
  
  RUN npm i
  
  COPY --chown=node:node . .
  
  EXPOSE 3000
  
  COPY ./docker-entrypoint.sh /docker-entrypoint.sh
  
  RUN chmod +x /docker-entrypoint.sh
  
  ENTRYPOINT ["/docker-entrypoint.sh"]
  </code></pre>
  
  <p>docker-entrypoint.sh:</p>
  
  <pre><code>#!/bin/sh
  
  npx sequelize-cli db:migrate
  
  npm run dev
  </code></pre>
  
  <p>Well, here I don't know how to run the migrates, because in my computer I only run <strong>"sequelize db:migrate"</strong>, I have a script in package.json too <strong>"migrate:dev": "NODE_ENV=development sequelize db:migrate"</strong></p>
  
  <p>for example.</p>
  
  <p>And the docker-compose.yml:</p>
  
  <pre><code>version: '3'
  
  services:
      app-app:
          container_name: app-app
          build: '.'
          volumes:
              - .:/home/node/api
              - /home/node/api/node_modules
          depends_on:
              - postgres-app
          networks:
              - app-connect
          ports:
              - '3000:3000'
  
      postgres-app:
          container_name: postgres-app
          image: postgres:11
          restart: unless-stopped
          volumes:
              - postgres-app-data:/data
          environment:
              POSTGRES_DB: ${DATABASE}
              POSTGRES_USER: ${DB_USER}
              POSTGRES_PASSWORD: ${DB_PASS}
          networks:
              - app-connect
  
  volumes:
      postgres-app-data:
  
  networks:
      app-connect:
          driver: bridge
  </code></pre>
  
  <p>But the migration not run yet. I have an error when I try run the docker-entrypoint.sh:</p>
  
  <pre><code>chmod: /docker-entrypoint.sh: Operation not permitted
  ERROR: Service 'app-app' failed to build: The command '/bin/sh -c chmod +x /docker-entrypoint.sh' returned a non-zero code: 1
  </code></pre>
  
  <p>If I remove all these items and only run npm start directly all works but when I try to access the app container to run the migrate show me the error:</p>
  
  <pre><code>docker exec -it 351 npm run migrate:dev                                                                 
  
  &gt; app@1.0.0 migrate:dev /home/node/api
  &gt; NODE_ENV=development sequelize db:migrate
  
  
  Sequelize CLI [Node: 12.14.0, CLI: 5.5.1, ORM: 5.21.3]
  
  Loaded configuration file "src/config/database.js".
  Using environment "development".
  
  ERROR: getaddrinfo ENOTFOUND postgres
  
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! app@1.0.0 migrate:dev: `NODE_ENV=development sequelize db:migrate`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the app@1.0.0 migrate:dev script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/node/.npm/_logs/2020-01-09T12_43_32_377Z-debug.log
  </code></pre>
  
  <p>How I can do this? Thanks!</p>