podbag Blog

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

Podbag Training · Open a web server in the browser

by The podbag team · on in TrainingPermalink

A web server listens on a port inside its container. Publishing a port gives your browser an address on your computer. In this module, the address is restricted to this computer.

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

Terminal
podbag lab install web-basics.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-basics
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.

Run the web server

Copy the command from the current step. It runs BusyBox and serves the file /www/index.html. The first run downloads the image.

Terminal
podbag run -d --name lab-web -p 127.0.0.1:18080:8080 docker.io/library/busybox:1.37.0 sh -c 'mkdir -p /www && printf "%s\n" "Podbag Training" > /www/index.html && exec httpd -f -p 8080 -h /www'
Run the web server

Check the port mapping in Desktop

Open Practice containers → lab-web → View ports. The default mapping is 127.0.0.1:18080 → 8080/tcp. The first port belongs to your computer. The second belongs to the container.

Check the port mapping in Desktop
Check the port mapping in Desktop

Open the page in the browser

Select Open in browser. The page shows Podbag Training. Desktop checks that the local address returns HTTP 200 and the expected text.

Open the page in the browser
Open the page in the browser

Stop the server in Desktop

Return to Practice containers. Find lab-web and select Stop in its row.

Stop the server in Desktop
Stop the server in Desktop

Remove the stopped container

Run the removal command in the same terminal. The next step appears when lab-web is gone.

Terminal
podbag rm lab-web
Remove the stopped container

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 · Keep files across containers