Difficulty: Intermediate
Estimated Time: 15 minutes

Warning: Under Construction

Docker is a containerization platform that packages applications and their dependencies together so that they can be easily deployed across multiple environments.

How are containers different from virtual machines?
Virtual machines encapsulate an entire operating system (called a guest OS) and provide a self-contained, isolated environemnt in which to run applications. Therefore, virtual machines are often multiple gigabytes in size. Containers package an application with the files and environment necessary for it to run. Rather than providing their own operating systems, containers get OS services from the operating system where they are deployed.

In this scenario we will deploy a Web application, a Microserrvice and a Cassandra cluster in Docker.

We will:

  • Create a Docker network
  • Pull the images from Docker Hub
  • Deploy the Cassandra cluster
  • Deploy the Microservice
  • Test the Microservice to database connection
  • Deploy the Web application
  • Test the Web application
  • Shut down the containers
  • Re-create the application using Docker compose

Let's get started!

In this scenario you used deplyed the Spring Reactive Pet Clinic application in Docker. The application consisted of three main parts, an Apache Cassandra™ database, a Spring Boot RESTful web service and an Angular web application.

You started by pulling an existing Cassandra image from DockerHub and starting a (single node) Cassandra cluster in a Docker container. Next you used a Dockerfile to create a Docker image with the Spring Boot service and ran it in another container. Then you created a Docker image with the Angular app and ran it in a container.

Finally, you shut down and removed all of the containers and restarted the application from the exsting Docker images. This showed how easy it is to deploy dockerized applications. Docker simplifies application deployment and is widely used in production environments. The challenge with Docker is scalability. As the number of Docker containers increases, it becomes more difficult to manage them.

There have been a number of solutions to manage or orchestrate containers. The leading solution for contianer deployment, scaling and managment is Kubernetes. Kubernetes is an open source container orchestration system originally developd by Google for managing internet scale production applications. The remainder of this course will focus on using Kubernetes to manage containerized applications.

Running Cassandra in Docker

Step 1 of 6

Create a Cassandra node in Docker

In this step, you will deploy a single Cassandra node in a Docker container. (Of course in a production environment we would create a cluster of multiple Cassandra nodes but for now we will create a single node.)

Start by creating a Docker network. Click the following.

docker network create cass-cluster-network

Click to pull an Apache Cassandra™ image from DockerHub.

docker pull cassandra

Start the Cassandra node using the Docker network we created earlier.

docker run -d --name nodeA --network cass-cluster-network cassandra

Click below to monitor the logs for nodeA.

docker logs -f nodeA

Watch until you see Startup Complete.

Startup Complete

Click to send a Ctrl-C to stop following the container's logs.

^C

Congratulations, you have a (singe node) Cassandra cluster running in Docker!