2

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...

St3an
  • 726
  • 1
  • 6
  • 21
  • 3
    The second port in `ports:` always needs to be the "normal" port inside the container the process listens to, so change this to `3308:3306`. – David Maze Oct 21 '20 at 14:15
  • thank you @DavidMaze, that is it :-) You save me a lot of pain... – St3an Oct 21 '20 at 14:24

0 Answers0