podbag Blog

Releases, engineering notes, benchmarks and hands-on training from the people who build podbag.

Podbag Training · Keep files across containers

by The podbag team · on in TrainingPermalink

A volume stores files that can survive container removal. Watch the animation and then try the same sequence with app-a and app-b.

Time 15 minutes

Beginner course

Run your first container → Open a web server in the browser → Keep files across containers → Replace and clean up a web service

Install the module

Download volume-persistence.podbag. In Desktop, select Install module at the top of Training. Choose the downloaded file and confirm.

Terminal
podbag lab install volume-persistence.podbag
Install confirmation with the module and file name

Start the practice session

Expand Training in the sidebar and select the module. Copy the start command into your terminal. Continue when it shows the training $ prompt.

Terminal
podbag lab start volume-persistence
Start the practice session

Create the volume

Create the named volume training-data in the practice session.

Terminal
podbag volume create training-data
Create the volume

Write a file from app-a

-v training-data:/data connects the volume to the container. The command writes note.txt and app-a exits.

Terminal
podbag run --name app-a --network none -v training-data:/data docker.io/library/busybox:1.37.0 sh -c 'printf "%s\n" "hello from app-a" > /data/note.txt'
Write a file from app-a

Remove app-a

Remove the stopped container. The volume stays in the practice session.

Terminal
podbag rm app-a
Remove app-a

Read the file from app-b

app-b mounts the same volume. The :ro suffix makes it read-only. The terminal displays hello from app-a.

Terminal
podbag run --name app-b --network none -v training-data:/data:ro docker.io/library/busybox:1.37.0 cat /data/note.txt
Read the file from app-b
Read the file from app-b

Remove app-b

Remove the second container to release the volume before you delete it.

Terminal
podbag rm app-b
Remove app-b

Open the volume details

Select Practice volumes → training-data. The details show its name and mount point.

Open the volume details
Open the volume details

Delete the volume in Desktop

Select Remove and confirm that the dialog names training-data. The volume and its file are deleted.

Delete the volume in Desktop
Delete the volume in Desktop

Check the volume list

Return to the same terminal. The volume list no longer contains training-data.

Terminal
podbag volume ls
Check the volume list

Finish the practice session

Run the command shown in the final step. Training records completion after the practice environment has been removed.

Terminal
exit
Finish the practice session
Training shows all steps complete

Next module · Replace and clean up a web service