Docker: Failed to connect to localhost port 80: Connection refused

Santhosh Yedidi

In my docker file while building i want to access files on my host machine from localhost server rather than copying them to the docker context folder (i.e the place where Dockerfile is located)

FROM busybox
RUN curl -L http://localhost/latest/myfile -o /root/myfile

I get errror:

$ docker build -t archlinux/test .
... from localhost : Failed to connect to localhost port 80: Connection refused

So how to do it.

Solution: to use localhost/file

Use IP of the localhost for that change the

Listen 127.0.0.1:80 to Listen 80

Or

Best solution is use --network=host

docker build --network=host -t test .
sadaf2605

If you are using Docker for Linux, You would need to use --network="host" as argument when you are running docker run or docker build command, then your host machine's localhost 127.0.0.1 will be accessible to your docker container.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Docker - Failed to connect to localhost port 4000: Connection refused

Docker: curl: (7) Failed to connect to localhost port 9089: Connection refused

Elasticsearch: Failed to connect to localhost port 9200 - Connection refused

curl (7): Failed to connect to localhost port 8000: Connection refused

Terminal curl: (7) Failed to connect to localhost port 3000: Connection refused

Laravel Dusk - Failed to connect to localhost port 9515: Connection refused

R Rselenium ".... Failed to connect to localhost port 4444: Connection refused"

curl: (7) Failed to connect to localhost port 8090: Connection refused

Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80))

Kurento Docker: Failed to connect to 127.0.0.1 port 8888: Connection refused

connect to host localhost port 22: Connection refused

Elasticsearch error curl: (7) Failed to connect to localhost port 9200: Connection refused but localhost:9200 works on browser

connect to 127.0.0.1 port 8080 failed: Connection refused

Failed to connect to '${ip}:${port}': Connection refused randomly

Port 80 connection refused

connect to localhost port inside the docker container is refused

Apache Atlas: curl: (7) Failed to connect to localhost port 21000: Connection refused

GItLab CI gives curl: (7) Failed to connect to localhost port 8090: Connection refused

Ubuntu 15.10 elasticsearch 2.3 Failed to connect to localhost port 9200: Connection refused

How to fix "Failed to connect to localhost port 9515: Connection refused" Laravel Dusk

TestRestTemplate HttpHostConnectException: Connect to localhost:8082 [localhost/127.0.0.1] failed: Connection refused

Connection refused - connect(2) for "localhost" port 25 chef devops

SSH :connect to host localhost port 22: Connection refused

Faraday::ConnectionFailed, Connection refused - connect(2) for "localhost" port 9200

curl: (7) Failed to connect to localhost port 9200: Connection refused. Even after having configured /etc/elasticsearch/elasticsearch.yml

curl: (7) Failed to connect to 192.168.99.100 port 31591: Connection refused

Failed to connect to port 8080: Connection refused Error number: 7 (cURL)

curl: (7) Failed to connect to 127.0.0.1 port 51786: Connection refused

Docker: Connection from inside the container to localhost:port Refused

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive