To update Node Exporter when running it as a Docker container (which is what you are doing in this lab), you generally follow three main steps.
Since Docker containers are usually static, you don't "update" the files inside them; instead, you replace the old container with a new one using the latest image.
Steps to Update
1. Pull the latest image
First, download the newest version from Docker Hub:
docker pull prom/node-exporter:latest
2. Stop and remove the old container
If you have a container currently running (let's assume it's named node-exporter), you need to stop it:
docker stop node-exporter
docker rm node-exporter
3. Start a new container
Run the container again using the same configuration you used previously. Docker will automatically use the new image you just pulled:
docker run -d --name node-exporter -p 9100:9100 prom/node-exporter
Pro Tip for DevOps
In a production environment, instead of manually updating, people often use:
- Docker Compose: You just run
docker-compose pullanddocker-compose up -d, and Docker handles the recreation for you. - Watchtower: A specific Docker tool that automatically watches for image updates and restarts containers with the new version.
For this lab, you are currently using the latest tag, so you already have the most recent version available at this moment! Happy learning!