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,170 points
126 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,060 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,530 points
1,700 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,290 points
239 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 20,068 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,100 points
1,037 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,060 points
1,192 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,060 points
120 views