MODULE 7 · TOPIC 5 · VISUAL DEVOPS LAB

Introduction to Containerization and Docker

Containerization packages an application and its runtime dependencies into an image, then starts isolated processes as containers. On Linux, containers share the host kernel; Docker Desktop generally runs Linux containers inside a VM on Windows or macOS. Containers are not full virtual machines, and isolation is not equivalent to a security guarantee.

Browser-based DevOps simulations. Commands, interfaces, logs and infrastructure states are illustrative; no Jenkins, Docker, Git hosting or Kubernetes operation is executed.

1. Virtual machine versus container

A virtual machine has its own guest OS kernel, whereas Linux containers use the kernel of the Linux environment hosting them. Images package user-space binaries, not a separate kernel for each container. Startup and overhead depend on workload and platform.

Why this example? Compare two teaching architectures for the same Java app.

Before you run: Choose a scenario and use Next step or Play. Read the diagram, command/configuration panel and simulated interface together. Code fragments require the indicated tools or existing project.
Why this step happens
See all steps in this scenario
    Commands and configuration
    Simulated terminal outputConsole
    Data operationsCompact blocks
    CurrentResultError / rejected

    Change inputs and step through the example. Simulated output. Exact logs, versions and UI appearance vary by installation.

    What this animation explains

    A virtual machine has its own guest OS kernel, whereas Linux containers use the kernel of the Linux environment hosting them. Images package user-space binaries, not a separate kernel for each container. Startup and overhead depend on workload and platform.

    Try and observe

    Trace the different layer responsibilities without treating illustrative resource figures as benchmarks.

    2. Image to running container

    An image is a read-only template made of filesystem layers and metadata. Docker creates a container with its own writable layer and launches a configured process. Stopping the process does not delete the image.

    Why this example? Run an image present locally or one that must first be downloaded.

    Before you run: Choose a scenario and use Next step or Play. Read the diagram, command/configuration panel and simulated interface together. Code fragments require the indicated tools or existing project.
    Why this step happens
    See all steps in this scenario
      Commands and configuration
      Simulated terminal outputConsole
      Data operationsCompact blocks
      CurrentResultError / rejected

      Change inputs and step through the example. Simulated output. Exact logs, versions and UI appearance vary by installation.

      What this animation explains

      An image is a read-only template made of filesystem layers and metadata. Docker creates a container with its own writable layer and launches a configured process. Stopping the process does not delete the image.

      Try and observe

      Notice how local availability changes the pull path.

      3. Package a Java application

      A Spring Boot executable JAR can be copied into a Java runtime image. The Dockerfile identifies base image, working directory, copy source and default command. Java class files must be compatible with the selected runtime.

      Why this example? Compare Java 21 runtime against an older Java 17 runtime for a JAR built with Java 21.

      Before you run: Choose a scenario and use Next step or Play. Read the diagram, command/configuration panel and simulated interface together. Code fragments require the indicated tools or existing project.
      Why this step happens
      See all steps in this scenario
        Commands and configuration
        Simulated terminal outputConsole
        Data operationsCompact blocks
        CurrentResultError / rejected

        Change inputs and step through the example. Simulated output. Exact logs, versions and UI appearance vary by installation.

        What this animation explains

        A Spring Boot executable JAR can be copied into a Java runtime image. The Dockerfile identifies base image, working directory, copy source and default command. Java class files must be compatible with the selected runtime.

        Try and observe

        Inspect the container exit reason rather than assuming image creation guarantees app startup.

        4. Container isolation and resource limits

        Namespaces isolate process views and cgroups can constrain resources. A memory limit bounds memory charged to a container; exceeding it can lead to OOM termination. The same application may need more memory than a tiny limit.

        Why this example? Compare simulated workload peak 180 MiB with two configured limits.

        Before you run: Choose a scenario and use Next step or Play. Read the diagram, command/configuration panel and simulated interface together. Code fragments require the indicated tools or existing project.
        Why this step happens
        See all steps in this scenario
          Commands and configuration
          Simulated terminal outputConsole
          Data operationsCompact blocks
          CurrentResultError / rejected

          Change inputs and step through the example. Simulated output. Exact logs, versions and UI appearance vary by installation.

          What this animation explains

          Namespaces isolate process views and cgroups can constrain resources. A memory limit bounds memory charged to a container; exceeding it can lead to OOM termination. The same application may need more memory than a tiny limit.

          Try and observe

          Identify the limit that allows the assumed workload to run.

          5. Container data and persistent storage

          Changes to the container writable layer survive stop and start but normally disappear when the container is removed. Named volumes are managed independently and can be attached to a replacement. Do not confuse container deletion with volume deletion.

          Why this example? Write a teaching file, remove the container and recreate it with or without a volume.

          Before you run: Choose a scenario and use Next step or Play. Read the diagram, command/configuration panel and simulated interface together. Code fragments require the indicated tools or existing project.
          Why this step happens
          See all steps in this scenario
            Commands and configuration
            Simulated terminal outputConsole
            Data operationsCompact blocks
            CurrentResultError / rejected

            Change inputs and step through the example. Simulated output. Exact logs, versions and UI appearance vary by installation.

            What this animation explains

            Changes to the container writable layer survive stop and start but normally disappear when the container is removed. Named volumes are managed independently and can be attached to a replacement. Do not confuse container deletion with volume deletion.

            Try and observe

            Check the file after recreation.

            6. Application stack with Docker Compose

            Compose describes related containers, networks and volumes in one YAML file. A service name is resolvable on its Compose network. Startup ordering alone is not a guarantee of application readiness; health checks and retry logic may be necessary.

            Why this example? Compare a backend ready and backend still initializing.

            Before you run: Choose a scenario and use Next step or Play. Read the diagram, command/configuration panel and simulated interface together. Code fragments require the indicated tools or existing project.
            Why this step happens
            See all steps in this scenario
              Commands and configuration
              Simulated terminal outputConsole
              Data operationsCompact blocks
              CurrentResultError / rejected

              Change inputs and step through the example. Simulated output. Exact logs, versions and UI appearance vary by installation.

              What this animation explains

              Compose describes related containers, networks and volumes in one YAML file. A service name is resolvable on its Compose network. Startup ordering alone is not a guarantee of application readiness; health checks and retry logic may be necessary.

              Try and observe

              Notice why a started container may not yet serve requests.

              Command and configuration reference

              Use these commands and settings with the corresponding installed tools in a disposable practice environment.

              Command / settingWhy and when to use it
              # Architecture: hardware → hypervisor → guest OS → JVM → appCompare two teaching architectures for the same Java app.
              docker run --rm hello-worldImage to running container — Run an image present locally or one that must first be downloaded.
              FROM eclipse-temurin:21-jreCompare Java 21 runtime against an older Java 17 runtime for a JAR built with Java 21.
              docker run --memory=128m --name demo-lab demo:1Container isolation and resource limits — Compare simulated workload peak 180 MiB with two configured limits.
              docker run --name data-lab alpine sh -c "echo hello > /tmp/note"Container data and persistent storage — Write a teaching file, remove the container and recreate it with or without a volume.
              services:Compare a backend ready and backend still initializing.

              Worked practical examples

              Follow the procedures in an isolated practice environment. Configuration snippets may require an existing project, build tools, credentials, images or cluster objects as indicated.

              1. Run and inspect a one-shot container

              Procedure

              1. Install and start Docker Engine or Docker Desktop.
              2. Run hello-world and inspect images and all containers.
              3. Compare --rm with a named exited container.
              Code / configuration
              docker run --rm hello-world
              docker run --name hello-lab hello-world
              docker ps -a
              docker image ls
              Expected result: One-shot containers exit; --rm removes only the first container automatically.

              2. Keep data in a named volume

              Procedure

              1. Create a dedicated volume.
              2. Write a file from one Alpine container and read it from another.
              3. Inspect the retained named volume.
              Code / configuration
              docker volume create notes-lab
              docker run --rm -v notes-lab:/data alpine sh -c "echo hello >/data/note"
              docker run --rm -v notes-lab:/data alpine cat /data/note
              Expected result: The second container prints hello.

              Predict the outcome before you run

              Try answering these questions, then expand each answer and repeat the appropriate simulation.

              1. Predict the final state for Container in “Virtual machine versus container”. Which operation explains it?

              Run Java as container process Result: java -version output.

              2. Predict the final state for Not cached in “Image to running container”. Which operation explains it?

              Remove exited container with --rm Result: Image retained.

              3. Predict the final state for Java 17 in “Package a Java application”. Which operation explains it?

              Use compatible runtime and rebuild Result: Container exited.

              Hands-on practice and assessment

              Hands-on challenge

              Install Docker in a practice environment and compare running nginx, stopping it, recreating it and keeping files in a named volume.

              Edit this command/configuration scratchpad. Review prerequisites and run only in your own isolated practice environment; the browser never executes commands.

              Quick assessment

              Official documentation

              Use the documentation for your installed tool versions and platform.

              https://docs.docker.com/get-started/

              https://docs.docker.com/engine/containers/run/

              https://docs.docker.com/engine/storage/volumes/

              Key points and real tool notes

              Use a local disposable practice environment and verify the active context, account, repository and names before running commands. Examples use Java 21, Maven 3.9, Jenkins Pipeline, Docker Engine and standard Kubernetes APIs. Logs and interfaces are educational reconstructions; versions, permissions, resources and real results can differ. No real deployments, credentials or network operations run in this page.