
什么是 Docker?它的作用是什么? Docker 是一种容器化技术,让你可以在计算机或服务器上运行应用程序,而无需手动安装复杂的环境。想象一下,你想在电脑上运行某个软件,通常需要安装各种依赖库、配置系统环境,甚至可能遇到版本冲突的问题。Docker 通过创建轻量级的容器,让每个应用程序都在独立的环境中运行,不会影响你的系统,也不会和其他软件发生冲突。 简单来说,Docker 的核心作用是: 隔离环境:每个应用都有自己的运行环境,不会影响宿主机。 快速部署:一次配置好,随时在任何地方运行,适用于云计算和服务器。 节省资源:相比传统的虚拟机(VM),Docker 容器更轻量,运行更快。 举个例子,你要搭建一个网站,传统方式可能需要手动安装数据库、Web 服务器等,而Docker 只需一条命令,就能快速运行所有必需的软件,极大提高效率。 什么是 Docker Compose?它的作用是什么? Docker 适合运行单个应用,但如果你的项目需要多个服务一起工作,比如:🔹 网站 = Web 服务器 + 数据库 + 缓存系统🔹 微服务架构 = 多个互相协作的容器 这时候,如果用传统方式,你需要手动启动每个 Docker 容器,并输入一大堆运行参数,非常麻烦。 Docker Compose 就是为了解决这个问题而生的!它是一个批量管理 Docker 容器的工具,通过一个 YAML 文件,你可以一次性定义并启动多个容器。 Docker Compose 的核心作用: 自动化管理:用一个文件(docker-compose.yml)描述所有服务,不用记复杂的命令。 一键部署:只需输入 docker-compose up,所有容器会自动启动。 适合团队开发:每个成员都能用同样的配置,避免环境不一致的问题。 举个例子,你在本地开发一个网站,需要数据库 + Web 服务器,传统方式要输入多个命令,而Docker Compose 只需要一个配置文件,一条命令即可启动所有服务,极大提升效率! 总结:Docker 让你轻松运行单个应用,而 Docker Compose 让你一键启动多个应用,两者结合,能让开发、测试和部署变得更简单、更高效。对于新手来说,学会 Docker 和 Docker Compose,能帮你快速上手服务器管理,避免繁琐的环境配置问题! 现在进入正题。。。 官方安装教程: ubuntu:https://docs.docker.com/engine/install/ubuntu/ debian:https://docs.docker.com/engine/install/debian/ centos:https://docs.docker.com/engine/install/centos/ 1、安装一些必要的软件包 apt update apt upgrade -y apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates 2、加入Docker的GPG公钥和apt源: Debian指令: curl -sSL 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://download.docker.com/linux/debian $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list Ubuntu指令: curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg echo "deb [arch=$(dpkg...

在更新Debian 10系统源时遇到的“Suite值从稳定切换到不稳定”的报错问题, root@debian:# apt-get update Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB] Get:2 http://deb.debian.org/debian buster InRelease [122 kB] Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB] Get:4 http://nginx.org/packages/mainline/debian buster InRelease [3604 B] Get:5 http://nginx.org/packages/mainline/debian buster/nginx amd64 Packages [46.3 kB] Reading package lists... Done E: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. N: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Version' value from '10.9' to '10.10' E: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details. E: Repository 'http://deb.debian.org/debian...

一般来说debian系统的VPS或者独立服务器默认都是用的22作为登录SSH的端口,由于弱密码等让一些喜欢扫描端口的怪胎可能有机可乘,就算登录不上也会消耗资源,那如何避免这样的情况呢?我们直接修改SSH默认登录端口22,改为其他的即可。 修改方法: 输入命令:nano /etc/ssh/sshd_config 将默认的Port 22修改为指定端口即可,示例,将端口修改为32873 Port 32873 然后ctrl +x ,退出并保存;提示是否保存,输入y 然后按enter确认。 如果你开启了防火墙,还需要修改防火墙规则里面的端口… 最后重启SSHD服务: systemctl restart sshd

debian11升级12傻瓜式教程:自从centos歇菜之后debian也新增了一波粉丝,队伍壮大了。当前,debian12出来了,抓紧尝鲜下吧,我们来简单、快速地将debian11升级到debian12吧,大致步骤如下: 先更新现有系统: apt update && apt upgrade 再修改debian11的源为debian12的: 如果是香港机器或者内地的机器,推荐用华为的源,复制以下代码直接回车即可: cat > /etc/apt/sources.list << EOF deb https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib deb-src https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib deb https://mirrors.huaweicloud.com/debian-security/ bookworm-security main deb-src https://mirrors.huaweicloud.com/debian-security/ bookworm-security main deb https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib deb-src https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib deb https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib deb-src https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib EOF 如果机器在欧美或者其他地方,推荐用linode的源,复制以下代码直接回车即可: cat > /etc/apt/sources.list << EOF deb http://mirrors.linode.com/debian bookworm main non-free-firmware deb-src http://mirrors.linode.com/debian bookworm main non-free-firmware deb http://mirrors.linode.com/debian-security/ bookworm-security main non-free-firmware deb-src http://mirrors.linode.com/debian-security/ bookworm-security main non-free-firmware deb http://mirrors.linode.com/debian bookworm-updates main non-free-firmware deb-src http://mirrors.linode.com/debian bookworm-updates main non-free-firmware EOF 继续更新和升级: apt update && apt full-upgrade 期间会有几次停顿下来,第一次要输入“q”,其余的全部“y” 最后重启系统: reboot