Docker cannot access mysql in the container through the host ip

  docker, question

As shown in the figure
图片描述

The setting here should be to map the 3306 of the container to the 3366 of the host, but I can only connect mysql services in the container through 192.168.99.100: 3366

The real ip of my host is 10.0.0.2

But I couldn’t connect it through 10.0.0.2: 3366, and asked the great god for advice.

图片描述

图片描述

Answer your question directly:
The reason why you have to pass192.168.99.100:3366To access the IP of the container instead of the host:10.0.0.2You used itToolbox, andToolboxIt is used by default.VirtualboxVirtual machines, so one more layer.

Drawing instructions:
图片描述

@ ClearWhat you said is also right. I suggest you use it.Docker for Mac,ToolboxWill be gradually abandoned.