First of all, it is better to discard any persistent data outside the image, so you made a good decision with that;).
Thus, to connect to the database located on the host machine, follow these steps:
- First you need to find the IP address of the host machine in the docker network. You can do this by typing
ip ain the console if you are using any Linux distribution, or ipconfig /allif you are using Windows. You can see the IP address next to the docker bridge adapter (if you use the default adapter, it should be docker0, and the line should start with inet). - Then, make sure that the database user does not have restrictions for connecting through an external network.
- (IP-), , , .
.