7

Im using centos 7.7 and docker 19.03.

I cannot pull images and getting :

Error response from daemon: Get https://registry-1.docker.io.v2./: dial tcp lookup : server misbehaving

I did what all guides on google suggested:

cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Enviroment="HTTP_PROXY=http://myproxy"

systemctl deamon reload
systemctl restart docker

and nothing happends. if i do echo $http_proxy i see my settings.

more settings: /etc/enviroment

http_proxy=http://myproxy
https_proxy=https://myproxy

The proxy setting used to work and is working on another server. On this server i had deleted docker old versions :

docker-1.13.1
docker-common-1.13.1
docker-client-1.13.1

With the older docker it seems to work but with docker-ce it doesnt. I even rebooted and reinstalled again.

Batchen Regev
  • 685
  • 1
  • 7
  • 28
  • Did you notice that `Environment` is misspelled in `/etc/systemd/system/docker.service.d/http-proxy.conf`? And that it's not `deamon` but `daemon` and they're attached by a hyphen: `daemon-reload` not a space. – Eric Feb 18 '23 at 09:33

3 Answers3

12

Solved it! I guess because i am using Centos then doing systemctl restart docker didnt really work.

Created the directory :

mkdir -p /etc/systemd/system/docker.service.d

Create the file :

nano /etc/systemd/system/docker.service.d/http-proxy.conf

Add the following line:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

Restart daemon:

systemctl daemon-reload

And this restart method worked:

service docker restart

and then it accepted all the env vars

Chris S
  • 422
  • 1
  • 4
  • 13
Batchen Regev
  • 685
  • 1
  • 7
  • 28
1

The latest documentation detailing the configuration of Docker to use Proxy server worked for me to build my latest docker image.

  • For latest docker clients (>= v17.07) create or edit the file ~/.docker/config.json

  • For older docker clients (<= v17.06) use the --env flag to set the proxy accordingly

neel
  • 184
  • 5
0

Set both variables, and they can both be set to your http server. The variable is for the type of traffic being proxied, not the protocol to the proxy server:

[Service]
Enviroment="HTTP_PROXY=http://myproxy"
Enviroment="HTTPS_PROXY=http://myproxy"
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • @batchenregev Let me know if this is helpful because I'd like to submit a PR on the documentation. – BMitch Nov 16 '19 at 10:44
  • I did this already, i did every possibility in the docs, all is the same. it seems like the docker service ignore this, if i put a filename in `Enviroment=/etc/defaults/docker` it seems to notice the change but saying " unknown option Enviroment", if you want be to try more things ill be there tomorrow – Batchen Regev Nov 17 '19 at 09:02
  • @BatchenRegev the output of `systemctl show docker | grep Env` may help. – BMitch Nov 18 '19 at 00:50
  • It comes empty, and i also did your exec example and it gives in `docker status` the same error im getting in the cli when i do `docker pull` shows the server misbehaving.. – Batchen Regev Nov 18 '19 at 08:53
  • @BatchenRegev coming back empty means you have not set the variable in systemd and there's no need to test docker commands until it does. Update your question to retrace your steps from the beginning, show the full output of each step and filename being modified. – BMitch Nov 18 '19 at 09:22
  • I did set it, see the answer i posted. it didnt take place because i was using `systemctl restart docker`, and it did worked as i did `service restart docker`. – Batchen Regev Nov 18 '19 at 09:40
  • @BatchenRegev centos 7 should be on systemd. Your answer indicates you aren't using that. Perhaps you have changed from the default install, or your question is inaccurate. – BMitch Nov 18 '19 at 11:00
  • it is weird as restart services with `systemctl` does work, but for this specific action to take place i had to do service restart, im just glad my problem is solved. – Batchen Regev Nov 18 '19 at 15:47
  • @BatchenRegev you stated not sure if that was a typo in your comment only, but "Enviroment" should be "Environment"... – D'Ante Barnes Oct 13 '22 at 00:16