1. 安装 Docker 安装必要的软件包 apt update apt upgrade -y apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates 修改 apt 源 curl -sS https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list 更新系统状态 Docker CE apt update apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin 添加用户到 docker 用户组 apt install docker-ce-rootless-extras sudo usermod -aG docker [USER] 2. 安装 Docker Compose 一般情况使用官方的 Github 地址进行安装,但是国内会因为网络问题下载的非常慢 curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-Linux-x86_64 > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose 可以使用 Ghproxy 进行代理安装 sudo curl -SL https://ghproxy.com/https://github.com/docker/compose/releases/download/v2.22.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose 安装完成记得修改权限 chmod +x /usr/local/bin/docker-compose 检查是否成功 root@debian ~ # docker-compose version Docker Compose version v2.18.1 3. 修改 Docker 配置 增加一段自定义内网 IPV6地址,开启容器的 IPV6 功能,以及限制日志文件大小,防止 Docker 日志塞满硬盘。 cat > /etc/docker/daemon.json << EOF { "log-driver": "json-file", "log-opts": { "max-size": "20m", "max-file": "3" }, "ipv6": true, "fixed-cidr-v6": "fd00:dead:beef:c0::/80", "experimental":true, "ip6tables":true } EOF