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

- 582
- 6
- 22

- 1,619
- 5
- 19
- 37
-
1If you are seeking for `docker-compose logs` type log aggregation, it's not yet implemented in docker swarm mode. If you need logs, all you can do (AFAIK) is to find out which node(s) host your container and use `docker logs
` directly. – ronkot Aug 09 '16 at 07:47 -
Do you mean: is there in Docker Swarm mode any way to track the events related to the lifecycle of services and associated tasks? – andov Oct 15 '18 at 18:12
2 Answers
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/

- 4,157
- 1
- 38
- 38
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 :-)

- 802
- 2
- 8
- 13