Skip to content

Instantly share code, notes, and snippets.

@johnharris85
Created July 25, 2019 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnharris85/ad0f9ec1637c31586871237d82daf647 to your computer and use it in GitHub Desktop.
Save johnharris85/ad0f9ec1637c31586871237d82daf647 to your computer and use it in GitHub Desktop.
compose logging test
{
"debug":true,
"experimental":true,
"metrics-addr":"0.0.0.0:9323",
"log-driver":"journald",
"log-opts":{
"tag":"{{.Name}}"
}
}
version: '3'
services:
web:
image: johnharris85/simple-hostname-reporter:3
container_name: test_container
....
Jul 25 10:42:29 jpersonal dockerd[5461]: time="2019-07-25T10:42:29.676128154-07:00" level=debug msg=event module=libcontainerd namespace=moby topic=/tasks/start
Jul 25 10:42:29 jpersonal test_container[5461]: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
Jul 25 10:42:29 jpersonal test_container[5461]: * Restarting with stat
Jul 25 10:42:29 jpersonal dockerd[5461]: time="2019-07-25T10:42:29.872058831-07:00" level=debug msg="sending heartbeat to manager { } with timeout 5s" method="(*session).heartbeat" module=node/agent node.id=mdmk0942jhclrg5veckgfspx7 session.id=lz7esjg63r658hpe5gq9afi43 sessionID=lz7esjg63r658hpe5gq9afi43
....
@helmut72
Copy link

Doesn't work. Still use the random hostname. Adding hostname: test_container to docker-compose.yml also doesn't help. Doesn't matter if log-opts is set to .Name or log-opts isn't set in daemon.json. log-driver is on both of my tests "journald"

@helmut72
Copy link

It works. But only if the logging driver is configured in docker-compose.yml:

    logging:
      driver: journald 
      options:
        tag: "{{.Name}}"

Ubuntu 18.04, Docker repo from docker.com. Possible a behavior of this combination. Tested on 2 Ubuntu 18 machines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment