Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Adding Metadata and Labels

For the last six months, the Acme Anvil Corporation has been migrating some of their bare-metal infrastructure to Docker containers. After the initial implementation, you mention to the team that labels can be used for storing metadata about images and containers. This is useful for keeping track of image and container attributes like the build date and application version. Your team thinks this is a great idea, and you’ve been tasked with creating a quick demo to show how useful labels can be. You created a small weather app a few months ago while learning Node.js, and it’s perfect for a quick demo. On your Docker workstation, you will create a Dockerfile that contains four labels: the maintainer, build date, application name, and application version. You will then build the image and push it to Docker Hub. On your Docker server, you will create a new container using the `weather-app` image. Once the container is running, you will update the branch of your application, rebuild the image, and push the changes to Docker Hub. On the Docker server, Watchtower will update the running container with the new version of the image.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
May 18, 2025
Duration
1h 0m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Create a Dockerfile

    Create a Dockerfile using the following instructions:

    FROM node
    
    LABEL maintainer="EMAIL_ADDRESS"
    
    ARG BUILD_VERSION
    ARG BUILD_DATE
    ARG APPLICATION_NAME
    
    LABEL org.label-schema.build-date=$BUILD_DATE
    LABEL org.label-schema.application=$APPLICATION_NAME
    LABEL org.label-schema.version=$BUILD_VERSION
    
    RUN mkdir -p /var/node
    ADD weather-app/ /var/node/
    WORKDIR /var/node
    RUN npm install
    EXPOSE 3000
    CMD ./bin/www
    
  2. Challenge

    Build the Docker Image

    Build the Docker image using the following parameters:

    docker build -t <USERNAME>/weather-app --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') 
    --build-arg APPLICATION_NAME=weather-app --build-arg BUILD_VERSION=v1.0  -f Dockerfile .
    
  3. Challenge

    Push the Image to Docker Hub

    Push the weather-app image to Docker Hub.

    docker push <USERNAME>/weather-app
    
  4. Challenge

    Create the `weather-app` Container

    Start the weather-app container.

    docker run -d --name demo-app -p 80:3000 --restart always <USERNAME>/weather-app
    
  5. Challenge

    Check Out Version v1.1 of the Weather App

    In the weather-app directory, check out version v1.1 of the weather app.

    cd weather-app
    git checkout v1.1
    cd ../ 
    
  6. Challenge

    Rebuild the `weather-app` Image

    Rebuild and push the weather-app image.

    docker build -t <USERNAME>/weather-app --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') /
    --build-arg APPLICATION_NAME=weather-app --build-arg BUILD_VERSION=v1.1  -f Dockerfile .
    
    docker push <USERNAME>/weather-app
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight