导读
环境:Ubuntu 22.04.5 LTS、Windows 11、WSL 2
背景:工作中用到了milvus、MySQL、mongodb、redis,milvus使用docker安装非常方便,而无法安装桌面版docker
时间:20250109
说明:Linux子系统的Ubuntu安装docker,运行milvus,镜像仅限当前测试能用
1、卸载与docker冲突的软件包
要卸载的非官方软件包包括:
该Ubuntu版本不存在需要卸载的包
docker.io
docker-compose
docker-compose-v2
docker-doc
podman-docker
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
2、设置docker的apt仓库
# 添加docker官方的 GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# 将docker加入到apt仓库:
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
sudo apt-get update
3、安装docker相关的包
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4、配置国内支持的镜像加速
镜像来源:2024年最新国内可用的Docker镜像加速器地址汇总
# 配置镜像加速
echo '{"registry-mirrors": ["https://docker.1ms.run"]}' | sudo tee /etc/docker/daemon.json > /dev/null
# 重新载入和重启docker
sudo systemctl daemon-reload && sudo systemctl restart docker
5、测试
sudo docker run hello-world
出现以下效果为成功:
jack@DESKTOP-MBL51MM:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:5b3cc85e16e3058003c13b7821318369dad01dac3dbb877aac3c28182255c724
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/