您尚未登录。

#1 2023-03-23 15:18:44

wenaho
会员
注册时间: 2023-03-23
帖子: 2

Docker下pacman和yay无法连接网络

环境配置如下:

[~]$ cat /etc/pacman.d/mirrorlist
Server = https://mirror.sjtu.edu.cn/archlinux/$repo/os/$arch

[~]$ tail -n 2 /etc/pacman.conf
[archlinuxcn]
Include = /etc/pacman.d/archlinuxcn-mirrorlist

[~]$ cat /etc/pacman.d/archlinuxcn-mirrorlist
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch

[~]$ echo $http_proxy
http://10.254.2.78:7890
[~]$ echo $https_proxy
http://10.254.2.78:7890

执行 sudo pacman -Syu 后,得到以下结果:

:: Synchronizing package databases...
 core downloading...
 extra downloading...
 community downloading...
 archlinuxcn downloading...
error: failed retrieving file 'core.db' from mirror.sjtu.edu.cn : Failed to connect to mirror.sjtu.edu.cn port 443 after 10001 ms: Timeout was reached
error: failed retrieving file 'extra.db' from mirror.sjtu.edu.cn : Failed to connect to mirror.sjtu.edu.cn port 443 after 10001 ms: Timeout was reached
error: failed retrieving file 'community.db' from mirror.sjtu.edu.cn : Failed to connect to mirror.sjtu.edu.cn port 443 after 10000 ms: Timeout was reached
warning: too many errors from mirror.sjtu.edu.cn, skipping for the remainder of this transaction
error: failed retrieving file 'archlinuxcn.db' from mirrors.ustc.edu.cn : Failed to connect to mirrors.ustc.edu.cn port 443 after 10000 ms: Timeout was reached
error: failed to synchronize all databases (download library error)

怀疑sudo之后没有走代理,于是尝试 sudo -E pacman -Syu,一切正常。
su到root后 echo $http_proxy 确实没有代理,尝试在 /root/.bashrc 添加代理,source之后重新切回普通用户, sudo pacman -Syu 仍报同样的错误。
感觉问题更应该是docker的问题,但是docker小白,在网上搜寻未果,希望有大佬能帮忙解答或者给个搜索关键字。

离线

#2 2023-03-23 15:26:19

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,934
个人网站

Re: Docker下pacman和yay无法连接网络

sudo 默认会重置环境变量,可以配置 sudoers 来加上要保持的环境变量。
sudo 执行命令时不读 ~/.bashrc。

离线

#3 2023-03-23 15:35:15

wenaho
会员
注册时间: 2023-03-23
帖子: 2

Re: Docker下pacman和yay无法连接网络

依云 说:

sudo 默认会重置环境变量,可以配置 sudoers 来加上要保持的环境变量。
sudo 执行命令时不读 ~/.bashrc。

感谢大佬,问题已经解决了!

离线

页脚