Docker Community Forums

Share and learn in the Docker community.

Get Docker 1.12 swarm mode events from python?

My docker version Docker version 1.12.1, build 23cf638, experimental. In older swarm, I used the below code to get the swarm events (I listened 127.0.0.1:4000)

import docker
swarmmaster_ip = "127.0.0.1:4000"

base_url = "tcp://"+swarmmaster_ip
cli = docker.Client(base_url)
events = cli.events(decode=True)
for event in events:
    print event
    print "Action",event["Action"]
    #print "ID",event['id'][:12]
    #print "NAME",event['Actor']['Attributes']['name']
    #print "NODE IP",event['node']['Ip']
    #print "NODE",event['node']['Name'] 
    print "****************"

But now 1.12, I don’t know which port should I listen to get swam events.

I did /usr/bin/docker daemon -H tcp://0.0.0.0:4342 -H unix:///var/run/docker.sock to listen docker on 4342 in master and slave

Port listening for docker in master

root@veeru:~# netstat -tulpn | grep docker
tcp6       0      0 :::2377                 :::*                    LISTEN      26809/dockerd    
tcp6       0      0 :::7946                 :::*                    LISTEN      26809/dockerd   
tcp6       0      0 :::4342                 :::*                    LISTEN      26809/dockerd   
udp6       0      0 :::7946                 :::*                                26809/dockerd

If I listen 4342, I only get node events not entire cluster event.

There’s no event support in swarm mode today, but it might come down the pipe someday.

1 Like

Is it available in 1.13 ?