I've setup 2 separate stacks with each one php + mariadb, via docker-compose. The first one has mariadb listening on 3306 port :

ports:
  - "3306:3306"

I use -p flag to build and up the second project so that things don't get mixed-up :

docker-compose -p project2 build && docker-compose -p project2 up

In the 2st project I had to change the listening port for mysql :

ports:
  - "3308:3308"

...otherwise the docker daemon says 3306 is already taken, which I understand seems logical

which gives the following, using docker ps -a :

 3306/tcp, 0.0.0.0:3308->3308/tcp

My problem is now that I cannot access the database from my windows host, I get this error :

ERROR 2013 (HY000): Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 11

I've tried several things in my mariadb2 Dockerfile

  • adding host.docker.internal to /etc/hosts.allow
  • adding bind-address=host.docker.internal (tried 127.0.0.1 too, 0.0.0.0 too) to /etc/mysql/my.cnf
  • EXPOSE 3308

I've tried to open firewall rules too from and to 3308 port/TCP

What could I do next ?... takes me hours to figure out how to get thing working...

1

There are 1 answers

0
Stanislav Panteleev On

I had similar error

Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0

In my case i stopped already installed MySQL and that is it! enter image description here