MySQL in Docker on Windows: World-writable files ignored
<p>I'm using Docker-Compose with the <a href="https://hub.docker.com/_/mysql/" rel="nofollow">MySQL Image</a> to fire up a MySQL database as part of a larger project.</p>

<p>As documented in the MySQL image's documentation, I'm mapping in a custom configuration file to <code>/etc/mysql/conf.d/config-file.cnf</code>:</p>

<pre><code>database:
  environment:
    MYSQL_ROOT_PASSWORD: foo
  ports:
    - "3306:3306"
  volumes:
    - "./mysql/conf.d/:/etc/mysql/conf.d"
  image: mysql:5.5
</code></pre>

<p>This works perfectly fine when running on Mac OS X as the host system (using <code>docker-machine</code>), but it fails when running on Windows (also using <code>docker-machine</code>). MySQL complains about the fact that the <code>/etc/mysql/conf.d/config-file.cnf</code> is world-writable</p>

<pre><code>Warning: World-writable config file '/etc/mysql/conf.d/config-file.cnf' is ignored 
</code></pre>

<p>When entering the database container, the file is indeed shown as having 0777 permission. This seems to be due to the host file system's permissions (Windows).</p>

<p>Is there any way to change this? I've tried mounting the volume in read-only mode, but the file still has the same permissions.</p>

<p>Any other way around this problem? At the moment, I'm mounting the file to another folder in the container and then copying/chmod'ing it to the required location as part of the startup command:</p>

<pre><code>database:
  environment:
    MYSQL_ROOT_PASSWORD: foo
  ports:
    - "3306:3306"
  volumes:
    - "./mysql/conf.d/:/usr/local/mysqlconf"
  image: mysql:5.5
  command: &gt;
    bash -c "

    cp /usr/local/mysqlconf/*.cnf /etc/mysql/conf.d/
    &amp;&amp; chmod 644 /etc/mysql/conf.d/*.cnf
    &amp;&amp; /entrypoint.sh mysqld
    "
</code></pre>

<p>Is there a better way to solve this issue?</p>