It's a bit late, but maybe the reason is not enough RAM. Add a swapfile. See https://forums.docker.com/t/var-lib-mysql-mysql-sock-is-not-created-sometimes/142851/5
RAM problem permanently solved by adding a swapfile. It remains strange that
the creation of the socket should have been prevented by the lack of memory and
that the error also occurs when setting up a swap file, but has no effect in this case.