Run Node Exporter Container on Port 9100
Now that you have the image, let's run the Node Exporter as a container. We will expose its metrics on port 9100, which is the default port for Node Exporter.
Execute the following command to start the container and place it on the same Docker network as Prometheus:
docker run -d -p 9100:9100 --name node-exporter --network monitoring prom/node-exporter
Let's break down this command:
-d: Runs the container in detached mode, meaning it runs in the background.
-p 9100:9100: Maps port 9100 of the host to port 9100 of the container.
--name node-exporter: Assigns a memorable name to the container for easy reference.
prom/node-exporter: The image to use for creating the container.
You can verify that the container is running with the docker ps command:
docker ps
You should see node-exporter in the list of running containers. Optionally, confirm the network attachment with:
docker inspect node-exporter --format '{{.HostConfig.NetworkMode}}'
The output should be monitoring.
Expected output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
... prom/node-exporter "/bin/node_exporter" A few seconds ago Up a few seconds 0.0.0.0:9100->9100/tcp, :::9100->9100/tcp node-exporter
... prom/prometheus "/bin/prometheus --c…" About a minute ago Up about a minute 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp prometheus