Ubuntu24.04下Docker安裝與配置

grovee發表於2024-07-03

安裝docker

官方教程加上代理

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings

curl指定代理

sudo curl -x http://127.0.0.1:7897 -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

配置APT代理

sudo vim /etc/apt/apt.conf

新增內容:

Acquire::http::Proxy "http://127.0.0.1:7897";
Acquire::https::Proxy "http://127.0.0.1:7897";

image

然後更新
sudo apt-get update

安裝docker

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

配置docker代理

sudo vim /etc/systemd/system/multi-user.target.wants/docker.service

在[Service]新增以下內容:

Environment=HTTP_PROXY=http://127.0.0.1:7897
Environment=HTTPS_PROXY=http://127.0.0.1:7897
Environment=NO_PROXY=localhost,127.0.0.1

image

重啟docker

systemctl daemon-reload
sudo service docker restart

測試

image

相關文章