How to connect to the localhost of the machine from the Docker container

0 votes

Hi Team,

I have launched one Docker container. I want to connect to the localhost of the machine from the Docker container. How can I do that?

Dec 23, 2020 in Docker by akhtar
• 38,260 points
11,584 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use --network="host" in your docker run command. It will connect the localhost or 127.0.0.1 in your docker container, will point to your docker host.

$ docker run --rm -it --network=host ubuntu
answered Dec 23, 2020 by MD
• 95,460 points

Related Questions In Docker

0 votes
1 answer

How to run a docker command from inside the container?

You must have come across the /var/run/docker.sock file, ...READ MORE

answered Jun 28, 2018 in Docker by Sophie may
• 10,620 points
3,544 views
0 votes
1 answer

Docker, how to get container information from within the container?

I've found out that the container id ...READ MORE

answered Jul 31, 2018 in Docker by Kalgi
• 52,350 points
962 views
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,220 points

edited Oct 16, 2018 by lina 34,234 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,737 views
0 votes
1 answer

How to find a Docker container IP address from the command line?

Hi@akhtar, You can use the docker inspect command ...READ MORE

answered Sep 4, 2020 in Docker by MD
• 95,460 points
4,068 views
0 votes
1 answer

unable to connect to docker container created via docker toolbox from browser of windows 8

Hi@Abhishek, You can't connect the docker container from ...READ MORE

answered Nov 16, 2020 in Docker by MD
• 95,460 points
1,031 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP