调用博主最近登录时间
生活中的HYGGE
学习强国部署查看docker容器输出和编写脚本清理输出

学习强国部署查看docker容器输出和编写脚本清理输出

hygge
2022-05-26 / 23 评论 / 2,141 阅读 / 正在检测是否收录...

1.前言

这最近学校要求每天都要看XueXiQiangGuo

l4amz85d.png

但是每天只拿一个打卡分怎么能满足得了我们程序猿呢!

于是找了找现成的开源应用(github search:techxuexi),每天稳定45+的低保收入

2.部署

1.先按照官网的操作拉下来镜像,查看一下拉取的镜像

docker images
# REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE
# techxuexi/techxuexi-amd64   latest    93418948958e   3 months ago   1.03GB

# 我后台已经跑了一个容器,先查看一下
docker ps -a
# CONTAINER ID   IMAGE                       COMMAND                  CREATED        STATUS             PORTS                                   NAMES
# 15956571b974   techxuexi/techxuexi-amd64   "/bin/bash ./start.sh"   38 hours ago   Up About an hour   0.0.0.0:9980->80/tcp, :::9980->80/tcp   techxuexi-web

2.先把运行着的容器停止

docker stop techxuexi-web
# techxuexi-web

3.运行起来

docker run   -ti --rm   --name=techxuexi-web   --shm-size="2g"   -e "ZhuanXiang=True"   -e "Pushmode=6"   -p "9980:80"   techxuexi/techxuexi-amd64
序号参数说明
1-ti容器会有一个可交互的输入终端
2--rm容器停止后会清除数据
3--name容器命名
4--shm-sizeallows you to specify the shared memory that a container can use
5-e多半是向容器内的程序传参
6-p容器内外端口映射

访问一下,一切正常
l4ger2ff.png

3.查看日志

web页面上的日志太少了,有时候开始刷半天也没有分数变化,可以进容器内部实时查看输出

docker logs -f techxuexi-web

l3mf7rf3.png

弊端嘛就是日志文件内容太多了,往往需要加载很久才到最新的位置,所以每次查看前都需要清空一下历史的log输出

4.编写shell

vim ~/cleanDockerLog.sh

######################### 以下是文件内容

#!/bin/sh
  
echo "======== start clean docker containers logs ========"
# /var/lib/docker/containers/ 是docker所有容器日志的存放地

# 通过find匹配到所有日志,$()命令替换,将bash命令替换成执行结果给logs

logs=$(find /var/lib/docker/containers/ -name *-json.log)

for log in $logs
        do
                echo "clean logs : $log"
                cat /dev/null > $log
        done

echo "======== end clean docker containers logs ========"

以后每次查看日志都可以先清理一下输出:
l3mfg129.png

5.修复每天45分

2022-05-25 docker版本照如下修改 才可以修复专项答题


# 1.进入到运行中的容器
docker exec -it techxuexi-web bash

# 2.安装vim
apt install vim

# 3.修改文件
vim /xuexi/pdlearn/answer_question.py

# 4.跳转到530行
530gg

# 5.修改
# weekly中quiz_xpath中的6改7
# zhuanxiang中quiz_xpath中的7改6

# 6.保存文件 退出容器
ZZ 然后 exit

# 7.重启容器
docker restart techxuexi-web
1

评论 (23)

取消
  1. 头像
    hygge 作者
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 101.0.4951.67 Google Chrome 101.0.4951.67

    05/24 更新了,自动只能拿30分表情

    回复
    1. 头像
      hygge 作者
        Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 101.0.4951.67 Google Chrome 101.0.4951.67
      @ hygge

      已修复,配合 hamibot 每天60+

      回复
      1. 头像
        lby
          Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 94.0.4606.71 Google Chrome 94.0.4606.71
        @ hygge

        hamibot请问有教程吗?我找不到这个脚本

        回复
        1. 头像
          hygge 作者
            Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 103.0.0.0 Google Chrome 103.0.0.0
          @ lby

          github:dundunnp/auto_xuexiqiangguo

          回复
  2. 头像
    纯情
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 96.0.4664.45 Google Chrome 96.0.4664.45

    你好,有没有docker desktop的教程,我用服务器搭建,试了好几个号都是最多30分,不会去做每周答题和专项答题

    回复
    1. 头像
      hygge 作者
        Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 102.0.0.0 Google Chrome 102.0.0.0
      @ 纯情

      文章最底部更新了修复教程 按照操作就可以修复45

      回复
      1. 头像
        春秋
          Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 102.0.5005.63 Google Chrome 102.0.5005.63
        @ hygge

        是不是docker目前只能45分了,要得分更多就只能上其他脚本了吗

        回复
        1. 头像
          hygge 作者
            Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 102.0.0.0 Google Chrome 102.0.0.0
          @ 春秋

          对的,得分更多就是那个pk了,挂机的就不能操作了,得自己开脚本

          回复
  3. 头像
    星星之火可以燎原
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 103.0.0.0 Google Chrome 103.0.0.0

    博主,我这有一个群辉980+闲置,公司送的一直没啥用,你要是有需求了也可以挂上,反正闲着也是闲着表情

    回复
    1. 头像
      hygge 作者
        Android 12 Android 12  /  Google Chrome 103.0.0.0 Google Chrome 103.0.0.0
      @ 星星之火可以燎原

      表情 可以呀,正好体验体验群晖

      回复
  4. 头像
    Ff
      Android 11 Android 11  /  Google Chrome 103.0.0.0 Google Chrome 103.0.0.0

    请问这个登录是会失效吗?还是要自己每天去服务器手动登录吗

    回复
    1. 头像
      hygge 作者
        Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 103.0.0.0 Google Chrome 103.0.0.0
      @ Ff

      会失效,应该只有12个小时有效期,需要每天都去看一下登录状态。

      回复
  5. 头像
    星梦
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 105.0.0.0 Google Chrome 105.0.0.0

    我用桌面版的docker安装了一下,后面的不知道咋操作了,能不能发个详细点的教程。谢谢

    回复
    1. 头像
      hygge 作者
        Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 104.0.0.0 Google Chrome 104.0.0.0
      @ 星梦

      详细教程请移步查看官方的文档,这里仅记录我遇到的问题。

      回复
      1. 头像
        hope
          Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 106.0.0.0 Google Chrome 106.0.0.0
        @ hygge

        官方文档在哪呀

        回复
    2. 头像
      hope
        Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 106.0.0.0 Google Chrome 106.0.0.0
      @ 星梦

      学习强国怎么操作呀

      回复
  6. 头像
    小ruai
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 106.0.0.0 Google Chrome 106.0.0.0

    这个怎么用,纯小白

    回复
  7. 头像
    hope
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 106.0.0.0 Google Chrome 106.0.0.0

    这个怎么使用啊?

    回复
    1. 头像
      hygge 作者
        Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 106.0.0.0 Google Chrome 106.0.0.0
      @ hope

      请自行Google

      回复
  8. 头像
    The
      Windows 10 x64 Edition Windows 10 x64 Edition  /  Google Chrome 109.0.0.0 Google Chrome 109.0.0.0

    可以尝试着部署一下study_xxqg UI也比这个好很多表情

    回复
  9. 头像
    adeng
      Windows 7 x64 Edition Windows 7 x64 Edition  /  Firefox 111.0 Firefox 111.0

    哪位大佬,能发邮箱里帮我布置系统吗?

    回复
  10. 头像
    raindecloud
      Mac OS X 10.15.7 Mac OS X 10.15.7  /  Google Chrome 112.0.0.0 Google Chrome 112.0.0.0

    2023-04-25 16:57:51最近半个月好像都无法用了,扫码登陆会报二维码失效

    回复
    1. 头像
      hygge 作者
        Android 12 Android 12  /  Google Chrome 112.0.0.0 Google Chrome 112.0.0.0
      @ raindecloud

      应该是吧,好久没用了

      回复