创建 lxc 容器时, 记得把非特权容器取消勾选。非特权容器中,无法使用非root用户运行 docker 命令
首先 更换 apt 源, 直接按照 ustc 源的操作步骤进行替换。
sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
apt update
apt upgrade
然后 添加普通用户
adduser wyntau
然后 安装git, zsh, curl sudo等命令
apt install git zsh curl sudo
安装 sudo 后,修改 /etc/sudoers 文件,将 wyntau 用户添加到 root 用户组中
然后 用新用户登录,配置 dotfiles git zsh
git clone --depth 1 https://github.com/wyntau/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
./install.sh git_config
./install.sh zsh_zim
重新登录前,可以把 zsh 配置更新
cat ~/.dotfiles/zsh/.zshr.common >> ~/.zshrc
然后 重新登录,使用环境变量生效,使用前面 zsh 配置中的源安装 homebrew
cd ~/.dotfiles
./install.sh homebrew
然后 重新登录, 使 homebrew 配置生效,使用 hombrew 安装 rustup, nvm 等工具
brew install rustup nvm
安装完成后,安装 rust 以及 node, pnpm 等
rustup-init
nvm install 22
npm install -g pnpm
然后 安装 docker, 使用 ustc 源进行安装
HTTPS_PROXY=xxx curl -fsSL https://get.docker.com -o get-docker.sh
sudo DOWNLOAD_URL=https://mirrors.ustc.edu.cn/docker-ce sh get-docker.sh
允许普通用户运行 docker 命令
sudo groupadd docker
sudo usermod -aG docker your_username
设置 docker 代理
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:8123"
Environment="HTTPS_PROXY=http://127.0.0.1:8123"
这里的127.0.0.1是直接用了本机的 http 代理,然后重启服务才能生效
sudo systemctl daemon-reload
sudo systemctl restart docker
可以通过sudo systemctl show –property=Environment docker看到设置的环境变量。
然后docker pull就会使用代理啦!