first commit

This commit is contained in:
seahi 2025-04-15 15:32:22 +08:00
commit d5c5d1d011
4 changed files with 58 additions and 0 deletions

14
Dockerfile.abnormal Normal file
View File

@ -0,0 +1,14 @@
# 使用轻量级的Alpine Linux作为基础镜像
FROM alpine:latest
# 安装bash (Alpine默认没有bash)
RUN apk add --no-cache bash
# 创建工作目录
WORKDIR /app
# 复制脚本到容器中
COPY abnormal.sh /app/
# 设置容器启动时执行的命令
CMD ["/bin/bash","/app/abnormal.sh"]

14
Dockerfile.normal Normal file
View File

@ -0,0 +1,14 @@
# 使用轻量级的Alpine Linux作为基础镜像
FROM alpine:latest
# 安装bash (Alpine默认没有bash)
RUN apk add --no-cache bash
# 创建工作目录
WORKDIR /app
# 复制脚本到容器中
COPY normal.sh /app/
# 设置容器启动时执行的命令
CMD ["/bin/bash","/app/normal.sh"]

16
abnormal.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
# 计数从1开始到15结束
for i in {1..15}
do
# 计算还剩多少秒
remaining=$((15 - i + 1))
# 输出当前状态
echo "${i}秒,还有${remaining}秒崩溃..."
# 等待1秒
sleep 1
done
echo "计时结束,发生崩溃!"
exit 1

14
normal.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# 计数从1开始到15结束
for i in {1..15}
do
# 计算还剩多少秒
remaining=$((15 - i + 1))
# 输出当前状态
echo "${i}秒,还有${remaining}秒退出..."
# 等待1秒
sleep 1
done
echo "计时结束,退出程序!"