Docker Events
Using Docker Events for Troubleshooting
Docker provides a command called docker events that allows you to monitor real-time events occurring in the Docker daemon. These events can be useful for debugging and understanding the behavior of your Docker environment. In this chapter, we will mainly focus on Docker events.
To start this section, let's run a MariaDB container and list its generated events:
# Run Docker event monitoring in the background
docker events
# Open a new terminal tab and run a MariaDB container
docker run --name mariadb -d \
-e MYSQL_ROOT_PASSWORD=password \
-v /data/db:/var/lib/mysql \
mariadb
The events launched by the last command can be seen using:
docker events
You will see a stream of events related to image pulling and container creation.
image pull mariadb:latest (name=mariadb ..
container create a4b64... (image=mariadb, name=mariadb, ..
network connect 5db80eaaeb88f33d28142c1ba87cbd80b4da0e341b15dd34a05dcdb5115691fe (container=a4b64..., name=bridge,..
container start a4b64... (image=mariadb, name=mariadb,..
The 4 events that were generated when we ran the MariaDB container are related to the following actions that Docker performed in the background:
image pull: The image is pulled from the public repository by its identifier MariaDB.container create: The container is created from the pulled image and is given a Docker identifier.network connect: The container is attached to a network calledbridge, which has a unique identifier. At this stage, the container is not running yet.container start: At this stage, the container is running on your host system with the same identifier.
In total, there are over 50 distinct events, varying based on the specific object in question. By 'objects,' we're referring to elements such as containers, images, plugins, volumes, networks, daemons, services, nodes, secrets, and configs. It's worth noting that while many of these events are tied to the Docker engine itself, others are specifically associated with Docker's orchestration solution, Docker Swarm. Following is a list of the most common events:
Docker containers report the following events:
attachcommitcopycreatedestroydetachdieexec_createexec_detachexec_dieexec_startexporthealth_statuskilloompauserenameresizerestartstartstoptopunpauseupdateDocker images report the following events:
deleteimportloadpullpushsavetaguntagDocker plugins report the following events:
enabledisable
Painless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
