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 .
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.
Comments