'Using a costum cnf with dockarized mysql

I have been trying to add a costum cnf file to mysql docker image but instead of using my settings it tries to apply it after and finds that it isn't compatible. How would I make it replace the default configuration for the docker mysql server instead of adding on to it?

  db:
    image: mysql:latest
    restart: always
    volumes:
      - db:/var/lib/mysql
      - /etc/mysql/docker/:/etc/mysql/conf.d #this is the problem

Anything that deviates from the original cnf and can't get set later gives an error. Example of an error:

[System] [MY-013577] [InnoDB] InnoDB initialization has ended.
[ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('0').
[ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
[ERROR] [MY-010119] [Server] Aborting

Example error 2:

[InnoDB] The Auto-extending innodb_system data file './ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages!


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source