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

Storing Container Data In Docker Volumes

Storing data within a container image is one option for automating a container with data, but it requires a copy of the data to be in each container you run. For static files, this can be a waste of resources. Each file might not amount to more than a few megabytes, but once the containers are scaled up to handle a production load, that few megabytes can turn into gigabytes of waste. Instead, you can store one copy of the static files in a Docker volume for easy sharing between containers. In this lab, you will learn how Docker volumes interact with containers. You will do this by creating new volumes and attaching them to containers. You'll then clean up space left by anonymous volumes created automatically by the containers. Finally, you'll learn about backup strategies for your volumes.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Sep 10, 2025
Duration
45m

Contact sales

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

    Discover Anonymous Docker Volumes
    1. View the currently available Docker images.
    2. List any existing Docker volumes.
    3. Run two postgres:12.1 containers in detached mode.
    4. Inspect the postgres containers to learn about the attached volumes.
    5. Run another detached postgres container using the --rm flag.
    6. List the Docker volumes, then shut down the postgres containers to see what effect that has on the volumes.
  2. Challenge

    Create a Docker Volume
    1. Create a Docker volume for the website code.
    2. Copy the website code into the volume from the host. You will need to use root permissions.
  3. Challenge

    Use the Website Volume with Containers
    1. Run an httpd container and mount the data volume. Expose container port 80 to view the website.
    2. View the webpage in a browser. Use the public IP address of your instance.
    3. Run another httpd container using the --rm flag. What do you expect will happen with the data volume when this container is stopped?
    4. List the current Docker volumes.
    5. Stop the temporary httpd container.
    6. List the Docker volumes again. Did the volume behave like you expected?
  4. Challenge

    Clean Up Unused Volumes
    1. Remove any volumes not currently in use.
    2. View the new list of volumes.
  5. Challenge

    Back Up and Restore the Docker Volume
    1. Inspect the website Docker volume to find its location on disk.
    2. Back up the Docker volume from the host by using tar to create a compressed archive.
    3. Back up the Docker volume from a container by mounting the volume and a backup data location to another container.
    4. Restore a backup.

    Note: Because the Docker data directories are protected, change to the root user for this task using sudo su - and the provided password.

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