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

Building a Docker Application Stack

Stacks are one of the most powerful orchestration features available in Docker Swarm. They allow you to easily manage complex applications consisting of multiple interdependent components running in separate containers. In this lab, you will have the opportunity to work with Docker stacks by building a multi-component application as a Docker stack. You will also learn how to manage existing stacks by scaling a stack's services after it has already been deployed. This will give you some hands-on insight into Docker stacks.

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

Contact sales

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

    Build and deploy the application stack.
    1. Create an empty project directory with a Docker compose YAML file inside.
    cd ~/
    mkdir produce
    cd produce
    vi produce.yml
    
    1. Build a stack definition in produce.yml to meet the provided specifications.
    version: '3'
    services:
      fruit:
        image: linuxacademycontent/fruit-service:1.0.1
      vegetables:
        image: linuxacademycontent/vegetable-service:1.0.0
      all_products:
        image: linuxacademycontent/all-products:1.0.0
        ports:
          - "8080:80"
        environment:
          - FRUIT_HOST=fruit
          - FRUIT_PORT=80
          - VEGETABLE_HOST=vegetables
          - VEGETABLE_PORT=80
    
    
    1. Deploy the stack using the compose file.
    docker stack deploy -c produce.yml produce
    
    1. Verify that the stack is working.
    curl localhost:8080
    

    Note that after deploying, it may take a few moments for the stack to become responsive. You can check the status of the services with docker stack services produce. Once the services are up and running, you should get some JSON data containing a combined list of fruits and vegetables.

  2. Challenge

    Scale the Fruit and Vegetable services in the stack.
    1. Set the number of replicas to 3 for the Fruit and Vegetable services in the compose file.
    vi produce.yml
    
    version: '3'
    services:
      fruit:
        image: linuxacademycontent/fruit-service:1.0.1
        deploy:
          replicas: 3
      vegetables:
        image: linuxacademycontent/vegetable-service:1.0.0
        deploy:
          replicas: 3
      all_products:
        image: linuxacademycontent/all-products:1.0.0
        ports:
          - "8080:80"
        environment:
          - FRUIT_HOST=fruit
          - FRUIT_PORT=80
          - VEGETABLE_HOST=vegetables
          - VEGETABLE_PORT=80
    
    1. Redeploy the stack using the compose file.
    docker stack deploy -c produce.yml produce
    
    1. Verify that the stack is still working.
    curl localhost:8080
    

    You should get some JSON data containing a combined list of fruits and vegetables.

    Use docker stack services produce to see that the number of replicas for the Fruit and Vegetable services is now 3.

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