mysqld: [ERROR] Found option without preceding group in config file /root/.my.cnf at line 1!
The default Dockerfile shell is sh. I don't think echo there has the -e modifier for backslash. Newline &amp; other special symbols will work by default. In your command, resulting .my.cnf would contain a litteral -e.
Remove -e or use the original command in Dockerfile in a different shell, for instance:
RUN /bin/bash -c '&lt;your-command&gt;'