Created
July 25, 2019 17:46
-
-
Save johnharris85/ad0f9ec1637c31586871237d82daf647 to your computer and use it in GitHub Desktop.
compose logging test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"debug":true, | |
"experimental":true, | |
"metrics-addr":"0.0.0.0:9323", | |
"log-driver":"journald", | |
"log-opts":{ | |
"tag":"{{.Name}}" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
web: | |
image: johnharris85/simple-hostname-reporter:3 | |
container_name: test_container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
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 | |
.... |
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
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"