Reputation: 39
Is it possible for my dockers that run Spring boot services to connect to a MySQL database running on the host?
Using the -p tag when running the docker is ineffective as port binding is not allowed if the port is in use
Upvotes: 0
Views: 44
Reputation: 1176
Yes, you can connect to MySQL DB running on the host.
All you need to do is run the docker container(that contain spring boot services) on host
network using --net host
in your docker run command.
Example:
docker run -itd --net host --name myapp myimage
Make a note that if you use the host network mode for a container, that container’s network stack is not isolated from the Docker host.
Read more about docker host networking here
Upvotes: 1