Skip to content

Instantly share code, notes, and snippets.

@HarshaSuranjith
Last active August 28, 2023 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarshaSuranjith/93fd24f60770f1ada6ea4ed6ab57542f to your computer and use it in GitHub Desktop.
Save HarshaSuranjith/93fd24f60770f1ada6ea4ed6ab57542f to your computer and use it in GitHub Desktop.
Docker Basics Exercises

Docker Learning Path: Extensive Learning

Task 1: Introduction to Containers

Final Evaluation

To understand the basics of containers, we'll create a simple Java program that prints "Hello, Containers!" to the console. We'll then package this program into a Docker image.

Docker Image: extensive-learning-intro-containers

Test Script (test_intro_containers.sh):

#!/bin/bash

docker run --rm extensive-learning-intro-containers

Task 2: Docker Basics

Final Evaluation

In this task, we'll go through the process of creating a Docker image containing a Spring Boot application. This application exposes a REST endpoint. We will deploy the image and verify access to the endpoint.

Docker Image: extensive-learning-docker-basics

Test Script (test_docker_basics.sh):

#!/bin/bash

docker run -d -p 8080:8080 --name docker-basics-app extensive-learning-docker-basics
sleep 5
response=$(curl -s http://localhost:8080/actuator/health)
docker stop docker-basics-app
docker rm docker-basics-app

if [[ "$response" == *"UP"* ]]; then
  echo "Test Passed: Docker Basics Application is running."
else
  echo "Test Failed: Docker Basics Application is not running."
fi

Task 3: Hands-on Docker Exercises

Final Evaluation

In this task, we will build a Docker image for a simple React app and run it as a container. We will then verify that the app is accessible from a browser.

Docker Image: extensive-learning-hands-on-exercises

Test Script (test_hands_on_exercises.sh):

#!/bin/bash

docker run -d -p 3000:3000 --name hands-on-exercises-app extensive-learning-hands-on-exercises
sleep 5
response=$(curl -s http://localhost:3000)
docker stop hands-on-exercises-app
docker rm hands-on-exercises-app

if [[ "$response" == *"React App"* ]]; then
  echo "Test Passed: Hands-on Exercises React App is accessible."
else
  echo "Test Failed: Hands-on Exercises React App is not accessible."
fi

Task 4: Docker Images and Registries

Final Evaluation

For this task, we'll create a Python script that pushes a sample Docker image to Docker Hub using the Docker API.

Docker Image: extensive-learning-docker-images

Test Script (test_docker_images.sh):

#!/bin/bash

python test_push_to_docker_hub.py

if [[ $? -eq 0 ]]; then
  echo "Test Passed: Docker image pushed to Docker Hub."
else
  echo "Test Failed: Docker image push to Docker Hub failed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment