Enable logging in docker mysql container : <p>I'm trying to get familiar with the docker ecosystem and tried to setup a mysql database container. With <code>docker-compose</code> this looks like:</p>

<pre><code>version: '2'
services:
  db:
    image: mysql:5.6.33@sha256:31ad2efd094a1336ef1f8efaf40b88a5019778e7d9b8a8579a4f95a6be88eaba
    volumes:
      - "./db/data:/var/lib/mysql"
      - "./db/log:/var/log/mysql"
      - "./db/conf:/etc/mysql/conf.d"
    restart: "yes"
    environment:
      MYSQL_ROOT_PASSWORD: rootpw
      MYSQL_DATABASE: db
      MYSQL_USER: db
      MYSQL_PASSWORD: dbpw
</code></pre>

<p>My conf directory contains one file:</p>

<pre><code>[mysqld]
log_error       =/var/log/mysql/mysql_error.log
general_log_file=/var/log/mysql/mysql.log
general_log     =1
slow_query_log  =1
slow_query_log_file=/var/log/mysql/mysql_slow.log
long_query_time =2
log_queries_not_using_indexes = 1
</code></pre>

<p>Unfortunately I don't get any log files that way. The setup itself is correct and the cnf file is used. After connecting to the container and creating the 3 files, <code>chown</code> them to <code>mysql</code> and restarting the container, the logging is working as expected.</p>

<p>I'm pretty sure that this is a common scenario, and my current way to get it running seems really stupid. <strong>What is the correct way to do it?</strong> </p>

<p>I could improve my approach by moving all this stuff in a Dockerfile, but this still seem strange to me.</p>
