0

I am trying to run a docker container on a minikube virtual machine, but I'm having trouble accessing the container.

Outside of minikube, I run container like so

docker run -d --rm -p 6717:6717 <image-name>

So, I'm mapping port 6717 of my host machine to port 6717 of the machine where docker is running.

And I would usually use http://locahost:6717 to send requests to the application running inside the container (which is a Fast API application, but I don't think that matters that much).

While using minikube, however, I can't seem to access the container.

I checked out this post: Unable to connect to running docker containers (minikube docker daemon).

The person seemed to have the issue issue that I had, but the suggested solution doesn't really solve my problem. In other words, instead of using localhost, I used the minikube VM's IP address like this

> minikube ip

Then tried to send requests to http://<minikube-ip>:6717. However, this also doesn't work.

I ssh'd into the VM like this:

> minikube ssh

and I can confirm that the application inside docker is running since I can do something like this successfully:

> curl http://localhost:6717

What am I missing exactly? I don't understand why I can't connect to the docker container using the minikube VM's IP address.

Blake_51
  • 101
  • Can you Refer to this [doc](https://pwittrock.github.io/docs/getting-started-guides/minikube/) and [SO](https://stackoverflow.com/a/70841630/19230181) by Affes Salem, might help you. – Hemanth Kumar Aug 07 '23 at 06:08
  • Can you please try this command `minikube ssh -- sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 6717 -j DNAT --to :6717`, if it did not work can you please show share the output of `docker ps -a | grep ` – Saifeddine Rajhi Aug 07 '23 at 08:55
  • Please let me know whether the shared info was helpful. I am happy to assist if you have any further queries. – Hemanth Kumar Aug 14 '23 at 03:46

0 Answers0