Exercise 5: Containerizing A Web Server Application§
-
The
Dockerfile
is available in /web/courses/cs3214/fall2022/exercises/ex5. -
TL;DR: Take your working p4 (including MP4 video streaming and HTML5 fallback) and build a container out of it. Run the container on an rlogin machine and demo it. Run a detached container with port forwarding enabled. If you run on, say,
leafytree
port14235
you would be demoing onhttps://leafytree-14235.cs3214.cs.vt.edu
where you would replaceleafytree
with the actual hostname of the rlogin node you're running on and14235
with your actual port number. But please listen to the video if you haven't used docker/podman before. -
❗ ❗ ❗ Please make sure to run
loginctl enable-linger
on the machine where your detached podman container runs. -
This video contains full instructions. Listening to the video, I discovered that I used some terms in an incorrect or too-loose manner, so here's a glossary:
-
a container - that's a bit ambiguous - it can refer to a running instance, or it can refer to an image. When not clear from context, it's important to understand the difference between the two, so here it is:
-
a container image - that's basically the contents of a virtual file system. It contains all files a typical Linux distribution would have, and on top everything that was explicitly added to this image when it was constructed. Container images are created and stored either in central repositories such as git.cs.vt.edu, hub.docker.com or quay.io, or locally on the computer you're working on. Container images are purely passive things.
-
container images are created using
docker build ...
using aDockerfile
, which is a recipe of how to build it. Often, images don't start from scratch, but a derivatives of others (docker'sFROM
keyword). Docker highly optimizes this process - shared content is downloaded only once and then used. -
a running container (instance) - that's one or more processes that have been started, but not yet exited, that use a container image as their starting point. These processes see (=read) the files in the image, but when they write (and make changes) those changes aren't applied to the image - these changes stay local in that particular running container instance. Such instances' filesystem state is preserved even when all processes that were running in the container exited - it can later be either removed, or it can be restarted.
-
in general, container instances are said to be stateless - that is, all changes they make are localized to the instance and are not reapplied to the image that was used to start them - somewhat like how processes start with the same global variable value, but changes to those global variables are not propagated back to the program's code and so do not affect the next time a program is run. (If this is not desired, and if persistency is desired instead, containers must be configured to mount (=provide access to) persistent volumes, which then appear in their file systems - for this demo, volumes are not required).
-
-
when your server is working, post the URL in the ex5 channel, unless you're doing the extra credit portion of the assignment also. Example: https://hazelnut-12345.cs3214.cs.vt.edu/
-
If you fail to set
loginctl enable-linger
on the machine you're running your container, before you run it, your containers may be killed when you log off. However, should this be happening, please start a new instance of your image (restarting the container doesn't seem to work). -
Please make sure that your pass all tests before demoing. The tests this semester are pretty exhaustive and should ensure that the React app runs.
-
Deadline for demoing ex5 is equal to your p4 deadline (possibly extended by late days). To meet the deadline, you must have posted your URL to the ex5 channel. If the TAs detect a defect in your demo, they'll tell you. You can fix it without missing the deadline (as long as you posted an initial, at least partially working version by the deadline). If you do the extra credit (below), you can skip this step - but be aware that fixing a non-working demo once deployed is more time consuming.
-
If you can't get p4 fully completed, you may demo for partial credit what you have (or the basecode). In this case, please make sure that the server's root directory is different from, and not a parent directory of, your
src
directory. In other words, don't expose your code to the world. -
Extra Credit Opportunity
For extra credit, we ask that you take a few additional steps and deploy your container on our department's discovery cluster. If you choose to do this, demo the container there instead (it'll count as your regular demo).
Please follow these steps.