通过docker在本地部署博客系统服务

通过docker拉取博客系统镜像

安装docker服务

1️⃣ 安装必要工具

bash 复制代码
sudo apt update
sudo apt install -y ca-certificates curl

2️⃣ 添加 Docker 官方 GPG 密钥和仓库(使用国内镜像源,避免网络问题)

bash 复制代码
# 创建密钥目录
sudo install -m 0755 -d /etc/apt/keyrings

# 下载阿里云镜像的 GPG 密钥(国内可用)
sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# 添加 Docker APT 仓库(使用阿里云镜像)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

3️⃣ 安装 Docker 引擎及相关组件

bash 复制代码
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

4️⃣ 启动 Docker 并设置开机自启

bash 复制代码
sudo systemctl enable docker
sudo systemctl start docker

5️⃣ 将当前用户加入 docker 组(避免每次输入 sudo)

bash 复制代码
sudo usermod -aG docker $USER

执行后需重新登录 (或运行 newgrp docker 临时生效)。

6️⃣ 配置镜像加速器(可选但推荐,用于加速拉取)

bash 复制代码
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://docker.m.daocloud.io"]
}
EOF
sudo systemctl restart docker

7️⃣ 验证安装

bash 复制代码
docker run hello-world

如果看到 Hello from Docker! 即安装成功。

确认启动了docker服务

复制代码
systemctl status docker

拉取博客系统镜像

复制代码
docker pull crpi-dnvvmwqk3y7594pa.cn-hangzhou.personal.cr.aliyuncs.com/blog_bite/blog_bite:V1.2

验证镜像是否成功拉取到docker里

复制代码
docker image ls

启动容器

复制代码
docker container run -itd -p 9090:8080 crpi-dnvvmwqk3y7594pa.cn-hangzhou.personal.cr.aliyuncs.com/blog_bite/blog_bite:V1.2

查看容器是否启动成功

复制代码
docker container ls

进入容器

复制代码
docker exec -it 64fe913cefb1[容器ID] bash

启动容器里的博客系统服务

1.启动MySQL服务

检查MySQL版本

复制代码
mysql --version

service mysql start

登录MySQL检查数据库表

复制代码
mysql -u root -p

数据库账号密码:root/BITE@yyds.666

查看数据库auto_test

复制代码
show databases;
复制代码
use auto_test;

show tables;

2.启动博客系统服务

复制代码
cd mmtest/
复制代码
nohup java -jar spring-blog-auto-test.jar &
复制代码
tail -f nohup.out
复制代码
 ps -ef | grep spring

访问搭建好的博客系统的服务

宿主机的IP:192.168.52.129

复制代码
ifconfig

登陆账号和密码:

复制代码
zhangsan/123456
lisi/123456
相关推荐
宋均浩18 分钟前
# Docker 镜像瘦身实战:从 1.2G 到 80MB 的五个优化步骤
ci/cd·docker
Avan_菜菜16 小时前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
程序员老赵17 小时前
10 分钟部署 OpenCode:Docker 一键安装,浏览器打开就能用 AI 写代码(附完整命令与排错)
docker·容器·ai编程
WangMingHua11121 小时前
LM Studio Docker 部署——本地大模型一键启动
docker
Sokach10151 天前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
SelectDB2 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao2 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
曲幽2 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
zzzzzz3103 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode3 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏