Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #19220

Re: [docker-compose] connect from docker to host

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: [docker-compose] connect from docker to host
Date Sat, 24 Dec 2022 23:21:43 +0100
Lines 41
Message-ID <k0pcbnFkm8lU1@mid.individual.net> (permalink)
References <to6oqj$gt8$2@gioia.aioe.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace individual.net KOTFG5aJ3rY5I24iQb51Rwsqd/jz6ugdhlU86BqCM/WWywVUwq
Cancel-Lock sha1:5+As8ZwtqPRp6LiGXBUwAVXv5kg=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0
Content-Language en-US-large
In-Reply-To <to6oqj$gt8$2@gioia.aioe.org>
Xref csiph.com comp.lang.php:19220

Show key headers only | View raw


On 24/12/2022 12.46, Custom Log wrote:
> + cat docker-compose.yml
> services:
>      web:
>          image: php:apache
>          extra_hosts:
>              - "host1:192.168.1.15"
>              - "host2:127.0.0.1"
> 
> + docker-compose run web php -r 'file_get_contents("http://host1:8010") 
> && print("OK!!!\n");'
> Creating host_web_run ... done
> OK!!!
> 
> + docker-compose run web php -r 'file_get_contents("http://host2:8010") 
> && print("OK!!!\n");'
> Creating host_web_run ... done
> Warning: file_get_contents(http://host2:8010): Failed to open stream: 
> Connection refused in Command line code on line 1
> 
> How to see
> 
> host1 work
> host2 not work
> 
> Why?

what is your host2 meant to be? the docker image itself or the host?

from the docker point of view, 127.0.0.1 is the docker itself.
if you want to access the host itself, then you need to use 
host.docker.internal

if you really want to access the dockers onw apache, then you have to 
configure that it listens to localhost/127.0.0.1.

Configure docker or apache are generally thought as off topic as it's 
nothing to do with PHP.

-- 
  //Aho

Back to comp.lang.php | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[docker-compose] connect from docker to host Custom Log <custom@log.abc> - 2022-12-24 12:46 +0100
  Re: [docker-compose] connect from docker to host "J.O. Aho" <user@example.net> - 2022-12-24 23:21 +0100

csiph-web