Docker安装配置手册

Debian系统安装Docker

安装依赖:

apt update
apt install ca-certificates curl gnupg

添加仓库(清华源):

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.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null

安装Docker:

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

验证安装:

docker --version
docker compose version

常用命令

进入容器:docker exec -it <容器id> /bin/bash

保存镜像:docker save <镜像名>:<镜像标签> | gzip > /home/<存储名称>.tar.gz

查看日志:docker logs <容器id>

作者:ossdate  创建时间:2024-10-27 16:40
最后编辑:ossdate  更新时间:2024-11-01 12:50