Cannot get Docker logging plugin to work (context deadline exceeded\)

Hello.
I am trying to get Docker to send logs to Loki in my local machine.

I have installed the docker loki plugin and have the following docker-compose file for my application, with the logging driver configured to loki:

version: "3.2"
services:
  database:
    container_name: database
    image: postgres:12
    volumes:
      - ./data/database:/var/lib/postgresql/data
    networks:
      - directus
    environment:
      POSTGRES_USER: "directus"
      POSTGRES_PASSWORD: "directus"
      POSTGRES_DB: "directus"

  cache:
    container_name: cache
    image: redis:6
    networks:
      - directus

  directus:
    container_name: directus
    image: directus/directus:v9.0.0-rc.24
    ports:
      - 8055:8055
    networks:
      - directus
    depends_on:
      - cache
      - database
    logging:
      driver: loki
      options:
        loki-url: "http://localhost:3100/loki/api/v1/push"

  loki:
    image: grafana/loki:2.0.0
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - directus

  promtail:
    image: grafana/promtail:2.0.0
    command: -config.file=/etc/promtail/config.yml
    networks:
      - directus

  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    networks:
      - directus

networks:
  directus:

But logs aren´t being sent to Loki.

I have the following in the docker daemon logs:

fev 13 09:39:16 bruno-zenbook dockerd[2226]: time="2021-02-13T09:39:16Z" level=info msg="level=warn ts=2021-02-13T09:39:16.828090565Z caller=client.go:322 container_id=0ca3e17e1690fb444fbc9e3842c9ee7e47b434e084d7c7c41ab8ffb022162fd8 component=client host=localhost:3100 msg=\"error sending batch, will retry\" status=-1 error=\"Post \\\"http://localhost:3100/loki/api/v1/push\\\": context deadline exceeded\"" plugin=2cbccd4c86ec719b9c6026ff1f69b2807130e5dd3fccb30c282f96e872afb97e

I am missing something?

Note that I can reach the loki endpoint using curl from my machine

Thank you.

directus uses loki service, but you don’t have any dependency. So in theory loki may not be started, when directus is starting. Add also dependency on loki service there, so docker daemon starts loki before directus.

Hmm, interesting. I added the loki dependency and it start working.

I was expecting that I could get some errors while loki was starting, but that it would recover after, without having to explicitly wait for loki to start before starting my application,