WSL设置相关:
代码语言:javascript复制wsl -l -v # 查看当前配置情况
正常配置如下:
代码语言:javascript复制 NAME STATE VERSION
* Debian Running 2
如果与以上有差异,按如下步骤进行配置:
代码语言:javascript复制wsl --set-version 2
wsl --set-default-version 2
wsl --set-default Debian
卸载残留包:
代码语言:javascript复制wsl
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
设置 Docker apt 官方仓库:
代码语言:javascript复制# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
安装最新版:
代码语言:javascript复制sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
安装指定版本:
代码语言:javascript复制# List the available versions:
apt-cache madison docker-ce | awk '{ print $3 }'
VERSION_STRING=5:24.0.7-1~debian.12~bookworm # 从列出的版本中选择自己需要的版本
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
将用户加入Docker组:
代码语言:javascript复制sudo usermod -aG docker $USER
启动docker服务:
代码语言:javascript复制sudo service docker start