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.
#!/bin/bash
docker run --rm extensive-learning-intro-containers
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.
#!/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
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.
#!/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
For this task, we'll create a Python script that pushes a sample Docker image to Docker Hub using the Docker API.
#!/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