前言
在Ubuntu,或者Debian系列的操作系统中,只提供了非官方的Docker安装包(Docker.io),安装Docker-CE(Docker官方维护的Docker),可能会遇到安装的不是docker的问题:
moetech@Virtual-Machine:~$ sudo apt remove wmdocker docker
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
linux-image-6.1.0-22-amd64
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
docker wmdocker
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 58.4 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 65852 files and directories currently installed.)
Removing docker (1.5-2) ...
Removing wmdocker (1.5-2) ...
Processing triggers for man-db (2.11.2-2) ...
但是,其实安装的不是docker,而是另一个包,这个是wmdocker。如果要正确安装docker,需要选择docker.io或者docker-ce,安装docker-ce则需要添加软件源。
开始安装
Step 1. 配置软件源
这里使用国内镜像源:https://mirrors.bfsu.edu.cn/docker-ce, 如用的是国外服务器,可以用官方源进行安装。
1. 安装依赖
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
不管有没有装,防止缺少依赖
2. 添加GPG公钥和软件源
Debian:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.bfsu.edu.cn/docker-ce/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
Ubuntu:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.bfsu.edu.cn/docker-ce/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 2. 开始安装
使用apt命令进行安装即可
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 3. 测试
使用docker version可以查看docker的版本信息,包括服务器和命令行工具
docker version
然后使用docker run hello-world
拉取并启动hello-world容器,如果没有出现报错就正常了
安装docker-compose
Step 1. 下载docker-compose
docker-compose在github上面有,具体可以到https://github.com/docker/compose/releases进行下载
使用wget命令:
wget https://github.com/docker/compose/releases/download/v2.29.2/docker-compose-linux-x86_64
Step 2. 重命名
mv docker-compose-linux-x86_64 docker-compose
Step 3.移动并赋予可执行权限
sudo mv docker-compose /usr/local/bin && sudo chmod +x /usr/local/bin/docker-compose
Step 4.查看docker-compose版本
docker-compose --version
参考文档:docker-ce | 镜像站使用帮助 | 北京外国语大学开源软件镜像站 | BFSU Open Source Mirror
Comments NOTHING