title: how to use custom.cnf in mysql server 8 docker-compose file?
body: <p>trying to use custom configuration file in docker-compose mysql 8. The docker-compose.yml looks like</p>
  <pre><code>version: '3'
  services:
    db:
      container_name: test-mysql8
      image: mysql/mysql-server:8.0
      volumes:
        - &lt;host path to&gt;/mycustom.cnf:/etc/mysql/conf.d/custom.cnf
      environment:
        - MYSQL_ROOT_PASSWORD=pass
        - MYSQL_DATABASE=testdb
        - MYSQL_USER=testuser
        - MYSQL_PASSWORD=testpassword
      ports:
        - &quot;3306:3306&quot;
      restart: always
  
    adminer:
      image: adminer:latest
      restart: always
      ports:
        - &quot;8080:8080&quot;
  </code></pre>
  <p>Below is the custom config file, mycustom.cnf</p>
  <pre><code>[mysqld]
  max_allowed_packet=32M
  character-set-server=utf8
  collation-server=utf8_bin
  transaction_isolation=READ-COMMITTED
  </code></pre>
  <p>Run the <code>docker-compose up -d</code> and verify the variables <code>docker exec -it test-mysql8 bash</code></p>
  <pre><code>mysql -p
  Enter password: 
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 8
  Server version: 8.0.23 MySQL Community Server - GPL
  
  Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  
  mysql&gt; show variables like '%max_allowed_packet';
  +---------------------------+------------+
  | Variable_name             | Value      |
  +---------------------------+------------+
  | max_allowed_packet        | 67108864   |
  | mysqlx_max_allowed_packet | 67108864   |
  | slave_max_allowed_packet  | 1073741824 |
  +---------------------------+------------+
  3 rows in set (0.00 sec)
  </code></pre>
  <p>Expecting the variable value as given in  <code>mycustom.cnf</code> as <code>max_allowed_packet=33554432</code> instead of <code>max_allowed_packet=67108864</code></p>
  <p>I know that command can be used in compose file as below, but I want to use custom file</p>
  <pre><code>......
  command: --character-set-server=utf8 --collation-server=utf8_bin --max-allowed-packet=32M --transaction-isolation=READ-COMMITTED
  ......
  </code></pre>