sope
sope

Reputation: 1821

How to log container in docker swarm mode

Is there a way to log the containers which are created with the docker service create in docker swarm mode?

Upvotes: 13

Views: 9103

Answers (2)

db80
db80

Reputation: 4427

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/

Upvotes: 17

Brice Argenson
Brice Argenson

Reputation: 832

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 :-)

Upvotes: 5

Related Questions