docker 無法從 LXC 容器內存取互聯網

docker 無法從 LXC 容器內存取互聯網

我使用以下命令在 RedHat 8.6 上啟動了 Ubuntu 20.04 LXC 容器

lxc launch ubuntu:20.04 --storage default -c security.privileged=true -c boot.autostart=true --network lxdbr0

我在容器中安裝了 docker,並配置了網路代理設置,/etc/systemd/system/docker.service.d/http-proxy.conf然後重新啟動了 docker 服務。


[Service]
Environment="HTTP_PROXY=<proxy address redacted>"
Environment="HTTPS_PROXY=<proxy address redacted>"

當我嘗試提取映像時出現 TLS 握手超時錯誤

root@still-katydid:~# docker pull nginx
Using default tag: latest
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: TLS handshake timeout

看看/var/log/syslog我可以看到一些錯誤

Dec  8 11:57:36 still-katydid dockerd[9606]: time="2022-12-08T11:57:36.486272382Z" level=warning msg="Your kernel does not support cgroup blkio weight"
Dec  8 11:57:36 still-katydid dockerd[9606]: time="2022-12-08T11:57:36.486290117Z" level=warning msg="Your kernel does not support cgroup blkio weight_device"
Dec  8 11:57:36 still-katydid dockerd[9606]: time="2022-12-08T11:57:36.487001498Z" level=info msg="Loading containers: start."
Dec  8 11:57:36 still-katydid dockerd[9606]: time="2022-12-08T11:57:36.489111401Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: WARNING: Module bridge not found in directory /lib/modules/4.18.0-372.9.1.el8.x86_64\nmodprobe: WARNING: Module br_netfilter not found in directory /lib/modules/4.18.0-372.9.1.el8.x86_64\n, error: exit status 1"
Dec  8 11:57:36 still-katydid dockerd[9606]: time="2022-12-08T11:57:36.591405424Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"

我知道代理地址設定是正確的,因為我也在我的.bashrc文件中配置了它們,並且我可以捲曲地址,例如https://www.bbc.co.uk成功地。

主機和容器中的防火牆均已停用。

我已多次重新啟動容器和主機。

答案1

我解決了我的問題。!我的密碼中有一個特殊字元。我已經用它逃脫了,%21但事實證明 docker 需要一個 double %%

因此,對於 docker 代理密碼,!需要使用轉義字符%%21

這裡有更多信息https://docs.docker.com/config/daemon/systemd/

相關內容