abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
17.73k stars 364 forks source link

Docker proxy settings problem #1040

Open MagicGopher opened 3 weeks ago

MagicGopher commented 3 weeks ago

Description

The daemon.json file does not take effect. daemon.json configures the following content.

{
  "proxies": {
    "default": {
      "httpProxy": "http://127.0.0.1:7890",
      "httpsProxy": "http://127.0.0.1:7890",
      "noProxy": "localhost, 127.0.0.1"
    }
  }
}

Version

colima version 0.6.9 git commit: c3a31ed05f5fab8b2cdbae835198e8fb1717fd0f

runtime: docker arch: aarch64 client: v26.1.4 server: v26.1.1

qemu-img version 9.0.0 Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

limactl version 0.22.0

Operating System

Output of colima status

INFO[0000] colima is running using QEMU INFO[0000] arch: aarch64 INFO[0000] runtime: docker INFO[0000] mountType: sshfs INFO[0000] socket: unix:///Users/{UserName}/.colima/default/docker.sock

Reproduction Steps

1.modify the daemon.json file to configure docker proxy 2.colima stop and colima start 3.after colima start, it is found that the proxy configured in daemon.json is not effective

Expected behaviour

After configuring docker proxy in daemon.json, the proxy should be used directly. However, when docker search or docker pull, it always shows proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused.

Specific commands.

docker search mysql
> Error response from daemon: Get "https://index.docker.io/v1/search?q=mysql&n=25": proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused
docker pull mysql
> Using default tag: latest
> Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused

Additional context

No response

MagicGopher commented 3 weeks ago

I use docker desktop for mac and orbstack to configure docker proxy and it works

MagicGopher commented 3 weeks ago

colima.yaml configures provision, the specific contents are as follows

provision:
  - mode: system
    script: |
      CLASH_PROXY="127.0.0.1:7890"
      echo "{\"proxies\": {\"default\": {\"httpProxy\": \"http://$CLASH_PROXY\", \"httpsProxy\": \"http://$CLASH_PROXY\", \"noProxy\": \"localhost,127.0.0.1\"}}}" | sudo tee /etc/docker/daemon.json
      sudo systemctl daemon-reload
      sudo systemctl restart docker
eunrui commented 2 weeks ago

colima start --edit

go to the last line

env: 
    http_proxy: http://192.168.5.2:7890
    https_proxy: http://192.168.5.2:7890
    no_proxy: localhost,192.168.5.2

quit then execute command

colima ssh sudo systemctl daemon-reload colima ssh sudo systemctl restart docker

it works for me

MagicGopher commented 2 weeks ago

colima start --edit

go to the last line

env: 
    http_proxy: http://192.168.5.2:7890
    https_proxy: http://192.168.5.2:7890
    no_proxy: localhost,192.168.5.2

quit then execute command

colima ssh sudo systemctl daemon-reload colima ssh sudo systemctl restart docker

it works for me

I have tried this method, but the colima virtual machine still does not use the proxy network.

MagicGopher commented 2 weeks ago

colima start --edit

go to the last line

env: 
    http_proxy: http://192.168.5.2:7890
    https_proxy: http://192.168.5.2:7890
    no_proxy: localhost,192.168.5.2

quit then execute command

colima ssh sudo systemctl daemon-reload colima ssh sudo systemctl restart docker

it works for me

Then I changed to the following method and it worked again.

provision:
  - mode: system
    script: |
      CLASH_PROXY="127.0.0.1:7890"
      echo "{\"proxies\": {\"default\": {\"httpProxy\": \"http://$CLASH_PROXY\", \"httpsProxy\": \"http://$CLASH_PROXY\", \"noProxy\": \"localhost,127.0.0.1\"}}}" | sudo tee /etc/docker/daemon.json
      sudo systemctl daemon-reload
      sudo systemctl restart docker

The .bash_profile file is configured

# proxy
function proxy_on() {
    export http_proxy="http://127.0.0.1:7890"
    export HTTP_PROXY="http://127.0.0.1:7890"
    export https_proxy="http://127.0.0.1:7890"
    export HTTPS_PROXY="http://127.0.0.1:7890"
}

# proxy off
function proxy_off() {
    unset http_proxy
    unset HTTP_PROXY
    unset https_proxy
    unset HTTPS_PROXY
}
eunrui commented 2 weeks ago

colima start --edit go to the last line

env: 
    http_proxy: http://192.168.5.2:7890
    https_proxy: http://192.168.5.2:7890
    no_proxy: localhost,192.168.5.2

quit then execute command colima ssh sudo systemctl daemon-reload colima ssh sudo systemctl restart docker it works for me

I have tried this method, but the colima virtual machine still does not use the proxy network.

Did u use http://192.168.5.2:7890 Or http://127.0.0.1:7890 ?

MagicGopher commented 2 weeks ago

colima start --edit go to the last line

env: 
    http_proxy: http://192.168.5.2:7890
    https_proxy: http://192.168.5.2:7890
    no_proxy: localhost,192.168.5.2

quit then execute command

it works for mecolima ssh sudo systemctl daemon-reload``colima ssh sudo systemctl restart docker

I have tried this method, but the colima virtual machine still does not use the proxy network.

Did u use http://192.168.5.2:7890 Or http://127.0.0.1:7890 ?

At first, I configured 127.0.0.1:7890 in the env property. Later, I saw similar problems in other issues and changed it to 192.168.5.2:7890. I found that no proxy was used.

liqiujiong commented 1 week ago

https://github.com/abiosoft/colima/issues/294#issuecomment-2158233093

MagicGopher commented 1 week ago

#294 (comment)

thanks