Inspect a single node
In this step, we will learn how to inspect a single Docker node. The docker node inspect
command provides detailed information about a specific node in a Docker Swarm.
First, let's check the version of Docker installed on the LabEx VM.
docker version
You should see output similar to this, indicating the Docker version is 20.10.21:
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.9
Git commit: baedd2f
Built: Tue Oct 25 17:58:10 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.9
Git commit: 305620d
Built: Tue Oct 25 17:56:04 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.10
GitCommit: b35cd9b83c7c7b1200458f9f9f8d73288d61e58e
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Now, let's initialize a Docker Swarm. This is necessary to have nodes to inspect.
docker swarm init
You should see output indicating the swarm has been initialized and providing a join token:
Swarm initialized: current node (xxxxxxxxxxxx) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 172.17.0.2:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
The output shows that the current node is now a manager. The xxxxxxxxxxxx
is the ID of the current node. We will use this ID to inspect the node.
Now, let's inspect the current node using its ID. Replace YOUR_NODE_ID
with the actual node ID from the docker swarm init
output.
docker node inspect YOUR_NODE_ID
For example, if your node ID was abcdef123456
, the command would be:
docker node inspect abcdef123456
This command will output a large JSON object containing detailed information about the node, including its status, role, hostname, and more.