Cannot download Docker images - no such host - docker

I have a web app on my home PC, which uses Docker. It works as expected.
I have installed Docker on my work PC. So far I have run: docker run hello-world and I see an expected result:
I then try: docker run --name some-mongo -d mongo:tag and I see this:
I have spent a lot of time looking into this. So far I have tried (in Docker for Windows Settings):
1) In Proxies; check 'Manual proxy configuration' and specify: http://proxy1:8080 as http and https proxy server (this is what is specified in Internet Settings).
2) In Network specify a fixed DNS server of: 8.8.8.8.
This has made no difference. What is the problem? Do I need to pass my username and password to the proxy server? I am confused why the command in screenshot 1 works as expected whilst the command in screenshot 2 does not.
I have Docker for Windows on a Windows 10 PC. I am using Linux containers.

Related

Accessing website hosted in a linux container from windows host

I have a linux container based on latest ruby image hosted in my windows laptop. I have a sample website running in the container. I can confirm that the website is running fine because running curl http://localhost:4000 with in the container returns the expected html. However, when I try to access the url from a browser in Windows it fails saying that it is not reachable. I am trying to figure out a way to access the sample app using browser in Windows.
Though I am trying to setup a ruby container (as I am trying to learn ruby), I am suspecting this is a networking problem with LCOW because I cannot ping the ip address of the container from Windows command prompt. It gives the error that "TTL expired in transit". Has anyone ever successfully tried a linux container on windows and accessing the website hosted in the container from windows? Could you please help me in figuring out what I am doing wrong or if I have to do something extra, like network route configuration, to make this working?
Further Details:
Docker version: 19.03.4
Host: Windows 10 Business Edition
Base Image: ruby on linux
docker run command used:
docker run -dit -p 4000:4000 --rm --name test updatedRubyImage
updatedRubyImage: This is a new image I created using base image. I installed a few gems on top of the base and commited it as a new image.

Simple Nginx server on docker returns 503

I'm just starting up with Docker and the first example that I was trying to run already fails:
docker container run -p 80:80 nginx
The command successfully fetches the nginx/latest image from the Docker Hub registry and runs the new container, there is no indication in CMD of anything going wrong. When I browse to localhost:80 I get 503 (Service Unavailable). I'm doing this test on Windows 7.
I tried the same command on another computer (this time on macOS) and it worked as expected, no issues.
What might be a problem? I found some issues on SO similar to mine, but they were connected with the usage of nginx-proxy, which I don't use and don't even know what it is. I'm trying to run a normal http server.
//EDIT
When I try to bind my container to a different port, for example:
docker container run -p 4201:80 nginx
I get ERR_CONNECTION_REFUSED in Chrome, so basically connection can't be established, because destination does not exist. Why is that?
The reason why it didn't work is that on Windows, Docker publishes results on different IP than localhost. This IP given is at the top in Docker client console.

Apache NIFI The request contained an invalid host header

I am trying to run Apache NIFI on a docker in my Rancher server. Rancher is running correclty as I have other services running. It is installed on a Debian box.
I am trying to test the official Apache Nifi container. As rancher's default port is 8080, I am trying to run it on another port. I am trying to run the first command as it is referenced in the documentation:
docker run --name nifi -p 9090:9090 -d -e NIFI_WEB_HTTP_PORT='9090' apache/nifi:latest
This gives me the error I mentioned in the title:
The request contained an invalid host header [xx.xx.xx.xx:9090] in the request [/nifi]. Check for request manipulation or third-party intercept.
I have tried to run it on a ubuntu laptop where docker is freshly installed and it started without problems.
If I get to the docker command line with docker exec -it nifi bash I see that I have no vi, nano nor any way of editing the nifi configuration file where I am supposed to change that information.
I have tried to create it directly from the rancher interface but it stays for a very long time just starting the container.
What I am doing wrong?
Apache NiFi 1.6.0 was just released (April 8, 2018) and the Docker image should update within the next few days to refer to that version. In 1.6.0, the host header handling was relaxed to be more user-friendly:
NIFI-4761 Host headers are not blocked on unsecured instances (i.e. unless you have configured TLS, you won't see this message anymore)
NIFI-4761 A new property in nifi.properties (nifi.web.proxy.host) was added to allow for listing acceptable hostnames that are not the nifi.web.http(s).host
NIFI-4788 The Dockerfile was updated to allow for this acceptable listing via a parameter like NIFI_WEB_PROXY_HOST='someotherhost.com'
I'm not familiar with Rancher, but I would think the container would have some text editor installed.
Finally Rancher through the Web itnerface and after a LONG wait has managed to start the container and it works.
I still don't know why on the command line it is not working, but now it is secondary.

localhost not working docker windows 10

I am using VS2017 docker support. VS created DockerFile for me and when I build docker-compose file, it creates the container and runs the app on 172.x.x.x IP address. But I want to run my application on localhost.
I did many things but nothing worked. Followed the docker docs as a starter and building microsoft sample app . The second link is working perfectly but I get HTTP Error 404 when tried the first link approach.
Any help is appreciated.
Most likely a different application already runs at port 80. You'll have to forward your web site to a different port, eg:
docker run -d -p 5000:80 --name myapp myasp
And point your browser to http://localhost:5000.
When you start a container you specify which inner ports will be exposed as ports on the host through the -p option. -p 80:80 exposes the inner port 80 used by web sites to the host's port 80.
Docker won't complain though if another application already listens at port 80, like IIS, another web application or any tool with a web interface that runs on 80 by default.
The solution is to:
Make sure nothing else runs on port 80 or
Forward to a different port.
Forwarding to a different port is a lot easier.
To ensure that you can connect to a port, use the telnet command, eg :
telnet localhost 5000
If you get a blank window immediatelly, it means a server is up and running on this port. If you get a message and timeout after a while, it means nobody is running. You anc use this both to check for free ports and ensure you can connect to your container web app.
PS I run into this just a week ago, as I was trying to set up a SQL Server container for tests. I run 1 default and 2 named instances already, and docker didn't complain at all when I tried to create the container. Took me a while to realize what was wrong.
In order to access the example posted on Docker Docs, that you pointed out as not working, follow the below steps,
1 - List all the running docker containers
docker ps -a
After you run this command you should be able to view all your docker containers that are currently running and you should see a container with the name webserver listed there, if you have followed the docker docs example correctly.
2 - Get the IP address where your webserver container is running. To do that run the following command.
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" webserver
You should now get the IP address which the webserver container is running, hope you are familiar with this step as it was even available within the building Microsoft sample app example that you attached with the question.
Access the IP address you get once running the above command and you should see the desired output.
Answering to your first question (accessing docker container with localhost in docker for windows), in Windows host you cannot access the container with localhost due to a limitation in the default NAT network stack. A more detailed explanation for this issue can be obtained by visiting this link. Seems like the docker documentation is not yet updated but this issue only exists in Windows hosts.
There is an issue reported for this as well - Follow this link to see that.
Hope this helps you out.
EDIT
The solution for this issue seems to be coming in a future Windows release. Yet that release comes out this limitation is available in Windows host. Follow this link -> https://github.com/MicrosoftDocs/Virtualization-Documentation/issues/181
For those who encountering this issue in 2022, changing localhost to 127.0.0.1 solved an issue for me.
There is other problem too
You must have correct order with parameters
This is WRONG
docker run container:latest -p 5001:80
This sequence start container but parameter -p is ignore, therefore container have no ports mapping
This is good
docker run -p 5001:80 container:latest

Docker Desktop for Windows: Cannot ping google.com from windows containers

I was creating a container using microsoft/windowsservercore image. And then when I tried to ping google.com from inside the container, I got this error:
Ping request could not find host www.google.com. Please check the name
and try again.
Then I switched to Linux Container mode in docker for windows. Then tried the same in an ubuntu container but this time it worked fine. Then when I switched back to Windows Container mode and tried the same thing again, it worked this time. Although my issue was resolved but I still don't understand what caused this issue in the first place ?
Docker for windows and linux have different default network settings.
Typically, the default for linux is bridged mode while in windows you have NAT.
You can alter your configuration with Network Connection Settings for windows
See: https://docs.docker.com/docker-for-windows/#network
The first option for me is always to look at the network section when executing docker inspect *containername*. This command gives you information about your network settings for the container. Other options are to check your firewall settings.
In general I usually use ping 8.8.8.8 since www.google.com cannot be pinged even from my standard windows machine.

Resources