環境変数
export http_proxy=<proxyのURL>
export no_proxy=<no_proxyのホスト>
cat <<EOF | sudo tee /etc/profile.d/proxy.sh
export http_proxy=${http_proxy}
export https_proxy=\${http_proxy}
export HTTP_PROXY=\${http_proxy}
export HTTPS_PROXY=\${http_proxy}
export no_proxy=${no_proxy}
export NO_PROXY=\${no_proxy}
EOF
source /etc/profile.d/proxy.sh
Apt
export http_proxy=<proxyのURL>
cat <<EOF | sudo tee /etc/apt/apt.conf.d/90proxy
Acquire::http::Proxy "${http_proxy}";
Acquire::https::Proxy "${http_proxy}";
EOF
Snap
export http_proxy=<proxyのURL>
sudo snap set system proxy.http=${http_proxy}
sudo snap set system proxy.https=${http_proxy}
確認方法
sudo snap get system proxy.http
sudo snap get system proxy.https
Docker
export http_proxy=<proxyのURL>
export no_proxy=<プライベートリポジトリがあれば、そのホストを指定>
sudo mkdir /etc/systemd/system/docker.service.d
cat <<EOF | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=${http_proxy}"
Environment="HTTPS_PROXY=${https_proxy}"
Environment="NO_PROXY=${no_proxy}"
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker.service
containerd
export http_proxy=<proxyのURL>
export no_proxy=<プライベートリポジトリがあれば、そのホストを指定>
cat <<EOF | sudo tee /etc/systemd/system/containerd.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=${http_proxy}" "HTTP_PROXY=${http_proxy}" "NO_PROXY=${no_proxy}"
EOF
sudo systemctl daemon-reload
sudo systemctl restart containerd.service