在Debian 12系统上安装Docker

Docker 在 Debian 12 上的安装

  • 安装
  • 验证
  • 测试
  • 更多信息

引言

在现代的开发环境中,容器技术发挥着至关重要的作用。Docker 提供了快速、可靠和易于使用的容器化解决方案,使开发人员和 DevOps 专业人士能够以轻松的方式将应用程序从一个环境部署到另一个环境。 Docker 的安装过程在 Debian 12 系统上非常简单,只需几条命令即可完成。在接下来的部分,我将详细介绍 Docker 的安装步骤和基本功能。

安装

安装 Docker 需要以下条件:

  • 已经安装的 Debian 12 系统 (VM 或硬件服务器)
  • root 权限

可以使用以下命令安装 Docker:

sudo su &&
apt update &&
apt install ca-certificates curl gnupg apt-transport-https gpg

下载 GPG 密钥并将其存储在系统中:

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" |tee /etc/apt/sources.list.d/docker.list > /dev/null 
apt update

安装 Docker 包:

apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose

验证

可以使用以下命令检查 Docker 是否安装成功并是否在系统启动时自动启动:

systemctl is-active docker

测试

也可以通过启动 hello-world Docker镜像来测试安装是否成功:

docker run hello-world

如果一切正常,将看到类似以下输出:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
478afc919002: Pull complete
Digest: sha256:03b30c6a3c320ff172b52bd68eddffde6ded08ce47e650fe52de861c5e9df46d
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.
    (arm64v8)
 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/

更多信息

有关 Docker 的更多信息,请参阅以下页面:

相关推荐
me8322 小时前
【Linux docker】关于Docker 守护程序配置远程访问,安全认证以及idea连接。
linux·安全·docker
笑远2 小时前
AWS容器化部署指南
docker·容器·aws
me8322 小时前
【Linux docker 容器】关于想要让虚拟机在开机时候也docker自己启动,容器也自己启动,省去要自己开docker和容器
java·linux·docker·云原生·eureka
nukix4 小时前
Docker Compose 部署 steamcmd 安装奈斯服务端
java·服务器·docker
法号:吃肉5 小时前
语音识别-FunASR-docker部署-【超简洁步骤】
人工智能·docker·语音识别
敏捷利齐5 小时前
docker不停机部署
运维·docker·容器
Narutolxy17 小时前
Ubuntu 下 Docker 企业级运维指南:核心命令与最佳实践深度解析20250309
运维·ubuntu·docker
Yuanymoon19 小时前
【由技及道】镜像星门开启:Harbor镜像推送的量子跃迁艺术【人工智障AI2077的开发日志010】
java·docker·jenkins·harbor·devops
dleei21 小时前
使用docker创建gitlab仓库
前端·docker·gitlab
Elastic 中国社区官方博客1 天前
使用 Elastic-Agent 或 Beats 将 Journald 中的 syslog 和 auth 日志导入 Elastic Stack
大数据·linux·服务器·elasticsearch·搜索引擎·信息可视化·debian