-1

I have a service defined via docker compose (see definition below). When I tried to start this service via docker-compose -f up --wait -d my_service, I get the error

Error response from daemon: failed to create task for container: failed to initialize logging driver: dial unix /dev/log: connect: protocol wrong type for socket

On my host server where I'm executing the docker compose cmd, I see the socket exists and my user has write perms:

srw-rw-rw-. 1 root root 0 Aug 29  2023 /dev/log

service definition:

  my_service:
    command: <omitted>
    image: <omitted>
    volumes:
      - "/dev/log:/dev/log"
    logging:
      driver: "syslog"
      options:
        syslog-address: "unix:///dev/log"
        tag: "my_service"

Does anyone know what could be causing this error?

1 Answer 1

0

Syslog over the network uses UDP sockets; UDP is a datagram-based protocol as opposed to the streaming style of TCP connections.

Similarly, syslog over Unix sockets uses a datagram protocol. That means you need to use unixgram:///dev/log instead of unix:///dev/log:

  my_service:
    command: <omitted>
    image: <omitted>
    volumes:
      - "/dev/log:/dev/log"
    logging:
      driver: "syslog"
      options:
        syslog-address: "unixgram:///dev/log"
        tag: "my_service"

The protocol options are documented in the syslog logging driver documentation.

See also the discussion on issue #18903.

7
  • I did see the linked discussion, but had thought it was resolved given wzyboy's linking to a merged PR that supposedly fixes the issue. These topics are quite new to me, but I see switching to unixgram does work indeed. Another thing that works is if I remove syslog-address. Why does it work in this case, and what is happening behind the scenes? Commented Sep 23, 2024 at 0:42
  • Actually if i don't specify a syslog-address, is it just defaulting to "unixgram:///dev/log" Commented Sep 23, 2024 at 0:45
  • RIght; that came up in the issue. Commented Sep 23, 2024 at 0:45
  • Thanks -- another question after reading up on unixgram is that messages sent aren't guaranteed to be in order, which might be problematic for my use case where I'm trying to log panic messages, which would be better if they were logged in order. Is there a way to enable ordering using syslog? Commented Sep 23, 2024 at 0:52
  • You would need a tcp-based (or streaming-socket based) logging service, and a corresponding logging driver. There are a number of logging drivers supported by docker. I'm not famliar with any of them, so I can't provide any guidance on that front. That said, I have never encountered a problem with out-of-order messages. Commented Sep 23, 2024 at 0:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.