U
U
UntitledNikname2021-03-10 10:41:09
Docker
UntitledNikname, 2021-03-10 10:41:09

Is it possible to reach localhost from the container?

tried php:7.2-apache image and webdevops/apache-dev:7.2.
Locally, there are a couple of nginx applications that run on port 80. Is it possible to reach them from the container by hostname ? It gives me 404.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mureevms, 2021-03-10
@UntitledNikname

For the localhost container, this is the container itself, so yes, you can).
To access the parent system, you must use the container's default gateway.
It can be found in two ways, the first is to find out the address on the dockerX interface:

$ ip a | grep docker
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0

Or make ip r in the container
$ sudo docker exec -it php-fpm sh
/ # ip r | grep default
default via 172.18.0.1 dev eth0

Where 172.17.0.1 is the required IP address that must be accessed from the container.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question