CentOS版本
如果您无法使用 Docker 的 rpm 存储库来安装 Docker Engine,您可以 下载适合您的版本的“.rpm”文件并手动安装。你需要 每次要升级 Docker 引擎时都下载一个新文件。
Install from a package
去 https://download.docker.com/linux/centos/ 并选择您的 CentOS 版本。然后浏览器x86_64/stable/Packages/
并下载您要安装的 Docker 版本的“.rpm”文件。
containerd.io_<version>_<arch>.rpm
docker-ce_<version>_<arch>.rpm
docker-ce-cli_<version>_<arch>.rpm
docker-buildx-plugin_<version>_<arch>.rpm
docker-compose-plugin_<version>_<arch>.rpm
例:CentOS_7.6_X86_64 为例:
下载链接:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
百度云盘链接:https://pan.baidu.com/s/1FQROZfmaJxNvMHIRzpY8iw
提取码:226m
如下:
containerd.io-1.6.24-3.1.el7.x86_64.rpm
docker-ce-26.1.4-1.el7.x86_64.rpm
docker-ce-cli-26.1.4-1.el7.x86_64.rpm
docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm
docker-compose-plugin-2.27.1-1.el7.x86_64.rpm
安装Docker 包
执行命令,如下:
sudo yum install ./containerd.io-1.6.24-3.1.el7.x86_64.rpm \
./docker-ce-26.1.4-1.el7.x86_64.rpm \
./docker-ce-cli-26.1.4-1.el7.x86_64.rpm \
./docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm \
./docker-compose-plugin-2.27.1-1.el7.x86_64.rpm
安装docker时出现缺少依赖项,如下:
Error: Package: docker-ce-rootless-extras-26.1.4-1.el7.x86_64 (docker-ce-stable)
Requires: slirp4netns >= 0.4
Error: Package: docker-ce-rootless-extras-26.1.4-1.el7.x86_64 (docker-ce-stable)
Requires: fuse-overlayfs >= 0.7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
在安装docker-ce-rootless-extras软件包时,缺少依赖项slirp4netns和fuse-overlayfs:
-
在线安装:
# 1、安装缺失的依赖项: sudo yum install slirp4netns fuse-overlayfs # 2、如果上述命令无法解决问题,尝试使用--skip-broken选项来跳过有问题的软件包: sudo yum install docker-ce-rootless-extras --skip-broken # 3、如果问题仍然存在,运行以下命令检查文件完整性: sudo rpm -Va --nofiles --nodigest
-
离线安装:
去http://mirror.centos.org/centos/7/extras/x86_64/Packages/对应依赖项slirp4netns和fuse-overlayfs,拷贝到CentOS系统目录上,后执行以下命令
sudo yum install ./fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm \ ./slirp4netns-0.4.3-4.el7_8.x86_64.rpm
-
重新执行安装安装Docker 包操作:
sudo yum install ./containerd.io-1.6.24-3.1.el7.x86_64.rpm \ ./docker-ce-26.1.4-1.el7.x86_64.rpm \ ./docker-ce-cli-26.1.4-1.el7.x86_64.rpm \ ./docker-buildx-plugin-0.14.1-1.el7.x86_64.rpm \ ./docker-compose-plugin-2.27.1-1.el7.x86_64.rpm
启动 Docker
# 1、第一种
sudo systemctl --now enable docker # 系统启动时自动启动Docker服务,并立即启动Docker服务。
# 2、第二种
sudo systemctl start docker # 启动docker服务
sudo systemctl enable docker # 设置docker服务开机自启
sudo systemctl status docker # 查看docker服务状态
验证docker
通过运行以下命令验证 Docker 引擎安装是否成功 “你好世界”图像。
sudo docker run hello-world
此命令下载测试映像并在容器中运行它。当。。。的时候 容器运行,它打印一条确认消息并退出。
您现在已经成功安装并启动了 Docker Engine。
Ubuntu版本
Install from a package
If you can’t use Docker’s apt
repository to install Docker Engine, you can download the deb
file for your release and install it manually. You need to download a new file each time you want to upgrade Docker Engine.
-
Select your Ubuntu version in the list.
-
Go to
pool/stable/
and select the applicable architecture (amd64
,armhf
,arm64
, ors390x
). -
Download the following
deb
files for the Docker Engine, CLI, containerd, and Docker Compose packages:containerd.io_<version>_<arch>.deb
docker-ce_<version>_<arch>.deb
docker-ce-cli_<version>_<arch>.deb
docker-buildx-plugin_<version>_<arch>.deb
docker-compose-plugin_<version>_<arch>.deb
-
Install the
.deb
packages. Update the paths in the following example to where you downloaded the Docker packages.$ sudo dpkg -i ./containerd.io_<version>_<arch>.deb \ ./docker-ce_<version>_<arch>.deb \ ./docker-ce-cli_<version>_<arch>.deb \ ./docker-buildx-plugin_<version>_<arch>.deb \ ./docker-compose-plugin_<version>_<arch>.deb
例如:
sudo dpkg -i ./containerd.io_1.6.24-1_amd64.deb \ ./docker-ce_26.1.4-1~ubuntu.20.04~focal_amd64.deb \ ./docker-ce-cli_26.1.4-1~ubuntu.20.04~focal_amd64.deb \ ./docker-buildx-plugin_0.14.1-1~ubuntu.20.04~focal_amd64.deb \ ./docker-compose-plugin_2.27.1-1~ubuntu.20.04~focal_amd64.deb
百度云盘链接:https://pan.baidu.com/s/1yTEIgdibfDpz1qIgNyEqIQ
提取码:aetvThe Docker daemon starts automatically.
-
Verify that the Docker Engine installation is successful by running the
hello-world
image.$ sudo service docker start $ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
You have now successfully installed and started Docker Engine.