Tuesday, 4 June 2019

Docker events: Get real time events from the server


‘docker system events’ command is used to get the real-time events.

$docker system events --help

Usage: docker system events [OPTIONS]

Get real time events from the server

Options:
  -f, --filter filter   Filter output based on conditions provided
      --format string   Format the output using the given Go template
      --since string    Show all events created since timestamp
      --until string    Stream events until this timestamp
$

Step 1: Execute the command ‘docker system event’.
$docker system events


Step 2: Open another terminal and execute the command ‘docker run hello-world’
$docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/


Step 3: Lets go to the terminal, where you ran the command ‘docker system events’, you can see below messages in console.

$docker system events
2019-04-26T11:36:43.071755400+05:30 container create 6a8513557062bd6198880e469f88fc10c212f2af8aabd35b09d1d1aae97ebef4 (image=hello-world, name=determined_chatterjee)
2019-04-26T11:36:43.077403100+05:30 container attach 6a8513557062bd6198880e469f88fc10c212f2af8aabd35b09d1d1aae97ebef4 (image=hello-world, name=determined_chatterjee)
2019-04-26T11:36:43.102607300+05:30 network connect 5cf7da2c3cb2f41de5868d08163469a852cfc52abea63a9fc1721a0850d577d6 (container=6a8513557062bd6198880e469f88fc10c212f2af8aabd35b09d1d1aae97ebef4, name=bridge, type=bridge)
2019-04-26T11:36:43.550564300+05:30 container start 6a8513557062bd6198880e469f88fc10c212f2af8aabd35b09d1d1aae97ebef4 (image=hello-world, name=determined_chatterjee)
2019-04-26T11:36:43.667509700+05:30 container die 6a8513557062bd6198880e469f88fc10c212f2af8aabd35b09d1d1aae97ebef4 (exitCode=0, image=hello-world, name=determined_chatterjee)
2019-04-26T11:36:43.974662000+05:30 network disconnect 5cf7da2c3cb2f41de5868d08163469a852cfc52abea63a9fc1721a0850d577d6 (container=6a8513557062bd6198880e469f88fc10c212f2af8aabd35b09d1d1aae97ebef4, name=bridge, type=bridge)




Previous                                                 Next                                                 Home

No comments:

Post a Comment