Is there a way to log the containers which are created with the docker service create
in docker swarm mode?
Docker manager nodes store the swarm state and manager logs in the /var/lib/docker/swarm/ directory. This data includes the keys used to encrypt the Raft logs.
All nodes in the swarm need to connect to the manager at the IP address. Because other nodes contact the manager node on its IP address, you should use a fixed IP address. You can run ifconfig on Linux or macOS to see a list of the available network interfaces. The tutorial uses manager1 : 192.168.
Finally that feature has been implemented in docker 17.03. You can get the logs of a service running on different/multiple nodes with this command:
docker service logs -f {NAME_OF_THE_SERVICE}
You can get the name of the service with:
docker service ls
Note that this is an experimental feature (not production ready) and in order to use it you must enable the experimental mode:
Update: docker logs service is now a standard feature of docker >= 17.06. https://docs.docker.com/engine/reference/commandline/service_logs/
The feature is not yet implemented. As @ronkot said, you have to figure out which node is running your service instance and connect directly to it.
Even if the feature will probably be implemented in the future, I strongly advice you to start to play with a Docker logging drivers in order to centralize all the logs of your cluster. Here is more information: https://docs.docker.com/engine/admin/logging/overview/
Fo example, the gelf driver is perfect if you want to use something like Logstash + Kibana :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With