accedere a localhost dall'interno di Docker

  • Creatore Discussione Creatore Discussione gio661
  • Data di inizio Data di inizio

gio661

Utente Attivo
8 Ott 2011
30
0
6
Codice:
+ curl localhost
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
bla bla bla...

Tutto ok, ma adesso proviamo dall'interno di un contenitore docker

Codice:
+ cat Dockerfile
FROM php:7.2.2-cli

+ cat test.sh
#!/bin/bash -e
cd $(dirname "$0")

docker build --network host -t test-image .
docker run test-image curl localhost

+ ./test.sh
Sending build context to Docker daemon 4.096 kB
Step 1/1 : FROM php:7.2.2-cli
 ---> 21c3582549e6
Successfully built 21c3582549e6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to localhost port 80: Connection refused

Perchè non funziona?
 

Discussioni simili