要在Debian上安装Docker,可以按照以下步骤进行:
更新系统软件包
在终端中执行以下命令,更新系统软件包:
sudo apt-get update
安装依赖包
在终端中执行以下命令,安装Docker需要的依赖包:
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
添加Docker官方GPG密钥
在终端中执行以下命令,添加Docker官方GPG密钥:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
添加Docker源
在终端中执行以下命令,添加Docker源:
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
更新软件包缓存
在终端中执行以下命令,更新软件包缓存:
sudo apt-get update
安装Docker
在终端中执行以下命令,安装Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io
安装成功输出:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gyp libjs-inherits libjs-is-typedarray libuv1 libuv1-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin
Recommended packages:
slirp4netns
The following NEW packages will be installed:
docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin
The following packages will be upgraded:
containerd.io docker-ce docker-ce-cli
3 upgraded, 3 newly installed, 0 to remove and 376 not upgraded.
Need to get 114 MB of archives.
After this operation, 30.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://download.docker.com/linux/debian buster/stable amd64 docker-buildx-plugin amd64 0.11.1-1~debian.10~buster [28.2 MB]
Get:3 https://download.docker.com/linux/debian buster/stable amd64 docker-ce-cli amd64 5:24.0.4-1~debian.10~buster [13.3 MB]
Get:4 https://download.docker.com/linux/debian buster/stable amd64 docker-ce amd64 5:24.0.4-1~debian.10~buster [22.9 MB]
Get:5 https://download.docker.com/linux/debian buster/stable amd64 docker-ce-rootless-extras amd64 5:24.0.4-1~debian.10~buster [9,034 kB]
Get:6 https://download.docker.com/linux/debian buster/stable amd64 docker-compose-plugin amd64 2.19.1-1~debian.10~buster [11.9 MB]
Fetched 114 MB in 33s (3,407 kB/s)
(Reading database ... 285893 files and directories currently installed.)
Preparing to unpack .../0-containerd.io_1.6.21-1_amd64.deb ...
Unpacking containerd.io (1.6.21-1) over (1.2.10-2) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../1-docker-buildx-plugin_0.11.1-1~debian.10~buster_amd64.deb ...
Unpacking docker-buildx-plugin (0.11.1-1~debian.10~buster) ...
Replacing files in old package docker-ce-cli (5:19.03.3~3-0~debian-buster) ...
Preparing to unpack .../2-docker-ce-cli_5%3a24.0.4-1~debian.10~buster_amd64.deb ...
Unpacking docker-ce-cli (5:24.0.4-1~debian.10~buster) over (5:19.03.3~3-0~debian-buster) ...
Preparing to unpack .../3-docker-ce_5%3a24.0.4-1~debian.10~buster_amd64.deb ...
Unpacking docker-ce (5:24.0.4-1~debian.10~buster) over (5:19.03.3~3-0~debian-buster) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../4-docker-ce-rootless-extras_5%3a24.0.4-1~debian.10~buster_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:24.0.4-1~debian.10~buster) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../5-docker-compose-plugin_2.19.1-1~debian.10~buster_amd64.deb ...
Unpacking docker-compose-plugin (2.19.1-1~debian.10~buster) ...
Setting up docker-buildx-plugin (0.11.1-1~debian.10~buster) ...
Setting up containerd.io (1.6.21-1) ...
Installing new version of config file /etc/containerd/config.toml ...
containerd.service is a disabled or a static unit not running, not starting it.
Setting up docker-compose-plugin (2.19.1-1~debian.10~buster) ...
Setting up docker-ce-cli (5:24.0.4-1~debian.10~buster) ...
Setting up docker-ce-rootless-extras (5:24.0.4-1~debian.10~buster) ...
Setting up docker-ce (5:24.0.4-1~debian.10~buster) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u8) ...
启动Docker服务
在终端中执行以下命令,启动Docker服务:
sudo systemctl start docker
设置Docker开机自启
在终端中执行以下命令,设置Docker开机自启:
sudo systemctl enable docker
输出:文章来源:https://www.toymoban.com/news/detail-661421.html
$ sudo systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
现在,已经成功在Debian上安装了Docker。文章来源地址https://www.toymoban.com/news/detail-661421.html
查看Docker的运行状态
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2023-07-18 03:57:47 CEST; 32s ago
Docs: https://docs.docker.com
Main PID: 15580 (dockerd)
Tasks: 10
Memory: 37.0M
CGroup: /system.slice/docker.service
└─15580 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jul 18 03:57:43 systemd[1]: Starting Docker Application Container Engine...
Jul 18 03:57:44 dockerd[15580]: time="2023-07-18T03:57:44.057726051+02:00" level=info msg="Starting up"
Jul 18 03:57:44 dockerd[15580]: time="2023-07-18T03:57:44.739870897+02:00" level=info msg="Loading containers: s
Jul 18 03:57:46 dockerd[15580]: time="2023-07-18T03:57:46.424897713+02:00" level=info msg="Loading containers: d
Jul 18 03:57:46 dockerd[15580]: time="2023-07-18T03:57:46.721701044+02:00" level=warning msg="WARNING: No swap l
Jul 18 03:57:46 dockerd[15580]: time="2023-07-18T03:57:46.721748129+02:00" level=info msg="Docker daemon" commit
Jul 18 03:57:46 dockerd[15580]: time="2023-07-18T03:57:46.721848335+02:00" level=info msg="Daemon has completed
Jul 18 03:57:47 dockerd[15580]: time="2023-07-18T03:57:47.436993967+02:00" level=info msg="API listen on /run/do
Jul 18 03:57:47 systemd[1]: Started Docker Application Container Engine.
检查Docker的版本信息
$ sudo docker version
Client: Docker Engine - Community
Version: 24.0.4
API version: 1.43
Go version: go1.20.5
Git commit: 3713ee1
Built: Fri Jul 7 14:50:58 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.4
API version: 1.43 (minimum version 1.12)
Go version: go1.20.5
Git commit: 4ffc614
Built: Fri Jul 7 14:50:58 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
到了这里,关于Linux Debian上快速安装Docker并运行的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!