title: Docker-Compose + Postgres: /docker-entrypoint-initdb.d/init.sql: Permission denied
body: <p>I have the following docker compose file:</p>
  
  <pre><code>version: "3"
  services:
    postgres:
      image: postgres:11.2-alpine
      environment:
        POSTGRES_PASSWORD: root
        POSTGRES_USER: root
      ports:
        - "5432:5432"
      volumes:
        - ./init-db/init-db.sql:/docker-entrypoint-initdb.d/init.sql
  </code></pre>
  
  <p>This is the init-db.sql:</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE users (
      email VARCHAR(355) UNIQUE NOT NULL,
      password VARCHAR(256) NOT NULL
  );
  
  CREATE TABLE products (
      id SERIAL PRIMARY KEY,
      title VARCHAR(100) NOT NULL,
      price NUMERIC(6, 2) NOT NULL,
      category INT NOT NULL
  );
  
  INSERT INTO users VALUES ('test@test.com', 'Test*123');
  INSERT INTO products (title, price, category) VALUES ('Truco', 9.90, 13);
  </code></pre>
  
  <p>When I run <code>docker-compose up</code>, I'm getting this error:</p>
  
  <pre><code>server started
  /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
  /docker-entrypoint-initdb.d/init.sql: Permission denied
  </code></pre>
  
  <p>I already tried to:</p>
  
  <ul>
  <li><code>chmod 777</code> on the sql file</li>
  <li><code>chmod -x</code> on the sql file</li>
  <li>Run docker and docker-compose using <code>sudo</code></li>
  </ul>
  
  <p>Any idea?</p>