podbag Blog

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

Podbag Training · Replace and clean up a web service

by The podbag team · on in TrainingPermalink

Replace a running web service while keeping its content. Use the same volume and local address before and after the replacement.

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 web-service-lifecycle.podbag. In Desktop, select Install module at the top of Training. Choose the downloaded file and confirm.

Terminal
podbag lab install web-service-lifecycle.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 web-service-lifecycle
Start the practice session

If the default port is already in use, use the port in Training. The command and browser address show the same port.

Create the site volume

Create site-data to hold the web page.

Terminal
podbag volume create site-data
Create the site volume

Start the first server

Start site-v1. It writes index.html to the volume and serves it on the published port. The default is 18081 on your computer.

Terminal
podbag run -d --name site-v1 -p 127.0.0.1:18081:8080 -v site-data:/site docker.io/library/busybox:1.37.0 sh -c 'printf "%s\n" "My Podbag site" > /site/index.html && exec httpd -f -p 8080 -h /site'
Start the first server

Check the first server ports

Select Practice containers → site-v1 → View ports. Check the address in the detail panel.

Check the first server ports
Check the first server ports

Open the first server page

Select Open in browser. Confirm that the page displays My Podbag site.

Open the first server page
Open the first server page

Stop the first server

Select Practice containers → site-v1 → Stop.

Stop the first server
Stop the first server

Remove the first server

Run the removal command. The container disappears and site-data stays in the practice session.

Terminal
podbag rm site-v1
Remove the first server

Start the replacement server

Start site-v2 on the same port. Mount site-data read-only. The server uses the page already stored in the volume.

Terminal
podbag run -d --name site-v2 -p 127.0.0.1:18081:8080 -v site-data:/site:ro docker.io/library/busybox:1.37.0 httpd -f -p 8080 -h /site
Start the replacement server

Check the replacement server ports

Select Practice containers → site-v2 → View ports. Confirm the address matches the first server.

Check the replacement server ports
Check the replacement server ports

Open the replacement server page

Select Open in browser again. The page still displays My Podbag site. Desktop checks the response with a new request.

Open the replacement server page
Open the replacement server page

Stop the replacement server

Select Practice containers → site-v2 → Stop.

Stop the replacement server
Stop the replacement server

Remove the replacement server

Remove the stopped container in the same terminal.

Terminal
podbag rm site-v2
Remove the replacement server

Open the site volume details

Select Practice volumes → site-data to see the remaining volume.

Open the site volume details
Open the site volume details

Delete the site volume

Select Remove and confirm the volume name.

Delete the site volume
Delete the site volume

Check the container list

List all containers in the practice session. The list is empty.

Terminal
podbag ps -a
Check the container list

Check the volume list

List the practice volumes. The list is empty.

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