简体   繁体   English

如何使用 Docker-compose 构建 Loki 服务器 Docker 映像

[英]How to build a Loki server Docker image using Docker-compose

I have created a directory and mounted all the required files in each directory but when I try to create the docker image, It creates Promtail and Grafana but the LOKI wouldn't create.我已经创建了一个目录并在每个目录中安装了所有必需的文件,但是当我尝试创建 docker 图像时,它会创建 Promtail 和 Grafana,但 LOKI 不会创建。 I get the error message below;我收到以下错误消息;

ERROR: for 9c35c983e8e4_cbxs_loki_1 Cannot start service loki: Mounts denied: You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.错误:对于 9c35c983e8e4_cbxs_loki_1 无法启动服务 loki:挂载被拒绝:您可以从 Docker 配置共享路径 -> 首选项... -> 资源 -> 文件共享。

I have mounted the files just as the order containers.. Please help我已经像订单容器一样安装了文件。请帮忙

docker-compose.yml docker-compose.yml

Please see the file on the link below https://docs.technotim.live/posts/grafana-loki/请查看以下链接中的文件https://docs.technotim.live/posts/grafana-loki/

version: "3"
networks:
  loki:
services:
  loki:
    image: grafana/loki:2.4.0
    ports:
      - "3100:3100"
    restart: unless-stopped
    command: -config.file=/etc/loki/loki-config.yml
    networks:
      - loki
  promtail:
    image: grafana/promtail:2.4.0
    volumes:
      - /var/log:/var/log
      - /Users/emma.egbu/CBCS/Promtail:/etc/promtail
    ports:
      - "1514:1514"
    restart: unless-stopped
    command: -config.file=/etc/promtail/promtail-config.yml
    networks:
      - loki
  grafana:
    image: grafana/grafana:latest
    user: "1000"
    volumes:
    - /Users/emma.egbu/CBCS/Grafana:/var/lib/grafana
    ports:
      - "3000:3000"
    restart: unless-stopped
    networks:
      - loki

Thank you so much.太感谢了。 That was helpful.., For anyone going through the same struggle: here was what I did.这很有帮助......,对于任何经历同样斗争的人:这就是我所做的。 I went to edit the docker daemon config file sudo nano /etc/docker/daemon.json - Probably you won't have write access so sudo vi chmod 666 /etc/docker/daemon.json - This will allow u write I pasted the file below我去编辑 docker 守护程序配置文件 sudo nano /etc/docker/daemon.json - 可能你没有写权限所以sudo vi chmod 666 /etc/docker/daemon.json - 这将允许你写我粘贴下面的文件

{
    "log-driver": "loki",
    "log-opts": {
        "loki-url": "http://localhost:3100/loki/api/v1/push",
        "loki-batch-size": "400"
    }

Afterwards I restarted my docker then also docker-compose up -d --force-recreate - to run up the docker-compose file之后我重新启动了我的 docker 然后docker-compose up -d --force-recreate - 运行 docker-compose 文件

You have defined a volume mount for /var/log in your container, but most likely don't have this defined in Docker Desktop (under Docker -> Preferences... -> Resources -> File Sharing).您已经在容器中为/var/log定义了卷安装,但很可能没有在 Docker 桌面(在 Docker -> 首选项... -> 资源 -> 文件共享下)中定义它。 You are probably best off removing this volume definition from the compose file, unless you actually want to read these logs on your Mac.您最好从撰写文件中删除此卷定义,除非您真的想在 Mac 上阅读这些日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM