frontail是一个 Node.js 应用程序,用于将日志流式传输到浏览器。这是一个tail -F带有用户界面的github原文 xnip2021-07-07_16-18-36.jpg

开始搭建测试环境

1,准备 Dockerfile

1FROM mthenw/frontail:4.9.1

2,编译镜像 docker build

1docker build -t halobug.cn/tails:4.9.1 .

build 成功截图 xnip2021-07-07_16-18-36.jpg

3,准备docker-compose 启动frontail+nginx测试

 1version: '3.6'
 2
 3services:
 4
 5  tails:
 6    container_name: tails
 7    image: halobug.cn/tails:4.9.1
 8    volumes:
 9      - ./logs/:/logs/
10      - /etc/localtime:/etc/localtime:ro
11      - /etc/timezone:/etc/timezone:ro
12    command: /logs/access.log
13    expose:
14      - 9001
15    restart: always
16    networks:
17      - traefik
18    labels:
19      - "traefik.enable=true"
20      - "traefik.docker.network=traefik"
21      - "traefik.http.routers.halobug-tails.entrypoints=https"
22      - "traefik.http.routers.halobug-tails.rule=Host(`tails.halobug.cn`)"
23      - "traefik.http.routers.halobug-tails.tls=true"
24      - "traefik.http.services.halobug-tails-backend.loadbalancer.server.scheme=http"
25      - "traefik.http.services.halobug-tails-backend.loadbalancer.server.port=9001"
26    logging:
27      driver: "json-file"
28      options:
29        max-size: "10m"
30  # 测试日志使用
31  local-halobug:
32    image: nginx:1.19.4-alpine
33    restart: always
34    expose:
35      - 80
36    volumes:
37      - ./logs:/var/log/nginx
38    networks:
39      - traefik
40    labels:
41      - "traefik.enable=true"
42      - "traefik.docker.network=traefik"
43      - "traefik.http.routers.local_halobug.entrypoints=https"
44      - "traefik.http.routers.local_halobug.rule=Host(`tails-nginx.halobug.cn`)"
45      - "traefik.http.routers.local_halobug.tls=true"
46      - "traefik.http.services.local_halobug-backend.loadbalancer.server.scheme=http"
47      - "traefik.http.services.local_halobug-backend.loadbalancer.server.port=80"
48    logging:
49      driver: "json-file"
50      options:
51        max-size: "1m"
52networks:
53  traefik:
54    external: true

4,启动容器&nginx

1docker-compose down && docker-compose up -d

5,绑定hosts

1127.0.0.1 tails.halobug.cn tails-nginx.halobug.cn

6,两个窗口分别输入网址测试

xnip2021-07-07_16-18-36.jpg

有利于开发人员及时排查问题

了解更多内容请访问 https://www.zhihu.com/people/halobug/posts