Docker doesn't connect under proxy - docker

My configuration is: Win 10 Pro; Virtual Box 6.0; in Virtual Box, Linux Mint Cinnamon 19.2; and in Linux I have Docker 19.03.5.
From my home connection all works fine and also Docker; I can, i.e., make a "search" without problems. At my work I have a proxy and proxy is well configured (Internet is available and also the browser works fine); for Docker proxy configuration, I have done exactly what is described in this official page https://docs.docker.com/network/proxy/ but Docker doesn't work. If I try a sudo docker search, I see a message:
Error response from daemon: Get https://index.docker.io/v1/search?q=mysql&n=25: dial tcp 52.6.213.218:443: i/o timeout
How can I fix the problem?
Edit
This is another response, if I try to run something:
user#User-VirtualBox-Mint:/$ sudo docker run hello-world
[sudo] password for user:
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.

Solution: the solution is in this forum
https://docs.docker.com/config/daemon/systemd/
I created a new folder /etc/systemd/system/docker.service.d and in this folder I created the file http-proxy.config. In this file I wrote the following line. Reload demon, restart docker and all works fine.
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:my_port/"
Environment="HTTPS_PROXY=http://127.0.0.1:my_port/"

Related

Docker, the proxy setting unworks and fails to pull a image like hello-world

I have install docker in my ubuntu 20.04 on WSL2(win10) fellow the offical doc on :
https://docs.docker.com/engine/install/ubuntu/
After the installation, I run: docker run hello-world for test. I receive the follow msg:
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
I am in a enviroment of my company, which would only visit "www.google.com" through a proxy.
In fact, through my setting proxy, I could get a
HTTP/1.0 200 OK
when running
curl -I www.google.com
While on the docker, I set up the proxy by creating the "https-proxy.conf" file in the direction of /etc/systemd/system/docker.service.d.
And write the context:
[Service]
Environment="HTTP_PROXY=http://usrname:psw#proxy.xxx.com:xxxx"
Environment="HTTPS_PROXY=http://usrname:psw#proxy.xxx.com:xxxx"
Environment="NO_PROXY=localhost,127.0.0.1,.xxx.com"
After that I just run:systemctl daemon-reload and systemctl restart docker by order.
Then I check if the proxy works, running systemctl show --property=Environment docker
I get a result as:
Environment=NO_PROXY=localhost,127.0.0.1,.xxx.com
Another two setting seem do not become effective. I have no idea what's wrong with the proxy setting while I want to make it aviable for docker. Would any one help me? thanks a lot!
Add below to /etc/default/docker file, then restart docker
export http_proxy="your proxy url""
export http_proxy="your proxy url"
export no_proxy="localhost"

install elastic search in docker

I used these two commands in cmd:
docker pull elasticsearch
show error:
Using default tag: latest
Error response from daemon: manifest for elasticsearch:latest not found: manifest unknown: manifest unknown
and this command with several different versions:
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.9.0
show error:
Error response from daemon: Get https://docker.elastic.co/v2/elasticsearch/elasticsearch/manifests/7.9.0: Get https://docker-auth.elastic.co/auth?scope=repository%3Aelasticsearch%2Felasticsearch%3Apull&service=token-service: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
how to resolve this problem?
please guide me.
latest version of elastic search does not work out of the box
https://github.com/elastic/elasticsearch-docker/issues/215
so, use specific version to install
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.11.1
Looking at your error message, while pulling the docker image, it seems that your network is blocking you to access the public docker repo to fetch the image.
request canceled while waiting for connection (Client.Timeout
exceeded while awaiting headers)
By any chance are you behind a VPN or firewall or having some restricition on public network/docker registry access?
docker run elasticsearch:{version} -d
use version, which you want to install
example -> docker run elasticsearch:8.4.3 -d
can other images be pulled?
Have you made any modifications to the docker default registry like adding new local registries to this file
/etc/containers/registries.conf
https://www.docker.com/blog/how-to-use-your-own-registry/
and also please check with the port rules for port 5000.
check your firewall, might likely be the culprit.
had the same issue running a compose file trying to pull image from image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION} i modified it to image: elasticsearch:${VERSION} and it worked. i.e. removing the docker.elastic.co/elastisearch part of the original url

Unable to find image 'hello-world:latest' locally

I have installed docker in my machine following the official installation steps for ubuntu. At the verification steps it fails.
When I run the command: docker run hello-world it throws following error message:
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-
1.docker.io/v2/: net/http: request canceled while waiting for
connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
Below are the docker details for my machine.
Client: Docker Engine - Community
Version: 19.03.6
API version: 1.40
Go version: go1.12.16
Git commit: 369ce74a3c
Built: Thu Feb 13 01:27:49 2020
OS/Arch: linux/amd64
Experimental: false
Got permission denied while trying to connect to the Docker daemon socket at
unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix
/var/run/docker.sock: connect: permission denied
If I tried for docker info I got the following message:
Client:
Debug Mode: false
Server:
ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/info: dial unix /var/run/docker.sock: connect: permission denied
errors pretty printing info
You can simply pull and test it in this way:
$ sudo docker pull hello-world
$ sudo docker run hello-world
First check if docker is running using
sudo service docker status
If its running, then you probably missed out adding your user to docker group. To confirm this, try docker commands with sudo
If you don't want to use sudo every time follow below guide to add you user to docker group
Step 2 — Executing the Docker Command Without Sudo (Optional)
NOTE : You can not run Docker in WSL i.e Ubuntu on Windows, so you need to install docker for windows, following guide provided complete steps of using Docker in WSL.
Setting Up Docker for Windows and WSL to Work Flawlessly
Post installation steps of docker are probably not executed. Basically, the current logged in used need to be added to docker group.
Just follow the instructions here from docker documentation - https://docs.docker.com/engine/install/linux-postinstall/
FYA- group membership evaluation would happen only after a reboot of ubuntu (in 18.04). So, after following the above link, reboot ubuntu machine. Then try docker images and permission issue reported should get resolved.
This problem has solved when I upgrade my ubuntu 19.04 to 19.10 and then reinstall it.
I had similar problem, while trying to fix the below error,
root#neno88:/home/mohan# docker run hello-world Unable to find image
'hello-world:latest' locally docker: Error response from daemon: Get
https://registry-1.docker.io/v2/: dial tcp: lookup
registry-1.docker.io on 10.187.215.112:53: read udp
10.187.215.103:58777->10.187.215.112:53: read: connection refused.
So, The error was due to the proxy in my enterprise setup, the daemon requests are refused via proxy
WRONG TRY to fix it, ( which caused error like above.)
I have added the registry-1.docker.io ip to the /etc/hosts, but it caused the similar error as in this StackOverflow here.
root#neno88:/home/mohan# docker run hello-world Unable to find image
'hello-world:latest' locally docker: Error response from daemon: Get
https://registry-1.docker.io/v2/: net/http: request canceled while
waiting for connection (Client.Timeout exceeded while awaiting
headers). See 'docker run --help'. root#neno88:/home/mohan#
CORRECT STEPS:
How to fix it,
Just add your Proxy details to the /etc/systemd/system/docker.service.d/proxy.conf (folder docker.service.d may not exists , so create the directory before)
After adding the proxy details check using the below commands , whether the daemon successfully see/read your environment variables.
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ systemctl show --property=Environment docker
Refer this doc: https://www.serverlab.ca/tutorials/containers/docker/how-to-set-the-proxy-for-docker-on-ubuntu/

Docker Error when proxy is set : proxyconnect tcp: dial tcp: lookup http: no such host

I am facing one weird issue with docker. We have a corporate proxy and using docker on Windows server 2016.
I am trying to pull docker image from dockerhub.
Started facing this issue recently. It was working fine earlier.
Steps
1) Set HTTP and HTTPS Proxy
2) Executed docker pull hello-world:nanoserver
Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: dial tcp: lookup http: no such host
Any idea whats going wrong here. I have couple of other machines having same setting and works fine.
Update 1: 06/03/2019
I did some trial and error and found that docker version is the culprit here.
I installed docker 17.06.2-ee-17, 17.06.2-ee-16 and tried pulling image. It worked fine.
So now question is what is wrong with latest 3 versions of docker ee for windows. i.e 17.06.2-ee-18,17.06.2-ee-19,17.06.2-ee-20 which is giving me this error.
We had exactly the same issues.
It appears to work in the newer versions when we used the fully qualified version of our proxy server.
i.e. http://proxy-server.my-domain.net:8080 instead of http://proxy-server:8080
Sorry, My answer is for Linux ("Error response from daemon: Get https://registry-1.docker.io/v2/:Proxyconnect tcp: dial tcp:lookup proxy.example.com:no such host")
Firsty check docker version with this command ($docker -v )
Output: Docker version 19.03.10, build 9424aeaee9 (Can be any version)
Check Can you ping to google ($ping google.com )
If it work, dont need to fix the file (/etc/hosts and /etc/resolv.conf)
$sudo snap install docker
Then check PATH environment variable
$echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin ( Output must be like this)
The output doesn't include /snap/bin path. You can define with below command
$export -n PATH=$PATH:/snap/bin
$echo $PATH ( check with this command )
Now login to docker hub
$docker login
When login succeeded,can pull any images from docker hub
$docker pull hello-world

Unable to find image 'hello-world:latest' locally Docker

This is the first time I am trying to set up docker (version 17.09.0-ce). I have followed the all instructions from official site and this run ok on my machine (Windows 10 x64). When I type docker --version on console returns Docker version 17.09.0-ce, build afdb6d4. But i am trying execute docker run -t hello-world and this is the answer:
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
my internet is from proxy, but I make a VPN and everything work perfectly except docker, I even install python packages using pip. what could be wrong?
I resolved this issue on windows 10 by resetting the DNS server to use the Google DNS fixed address: 8.8.8.8 (docker documentation)
This should resolve the issues for most.
For windows behind a proxy, you can do the followings to resolve this issue
go to your proxy setting under resources and enter your proxy credentials
username:password#yourdomain:port.
Important make sure to account for special character Unicode conversion
for example, if you have # in your password then you replace it with: %23
you can covert special characters via site.
I resolve this modifing daemon.json and put my proxy there. In case of Windows on Docker Desktop, go to Resources, Proxies:
For users in China, I recommand this answer.
You need to add a valid address to pull the image "hello-world".

Resources