hands-on lab

Using a Dockerfile and Docker-Compose to Build and Run Containers

Difficulty: Beginner
Duration: Up to 1 hour and 30 minutes
Students: 1,328
Rating: 4.7/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

If you're building and deploying cloud native applications and microservices, then understanding container development and orchestration is a must have skill. In this Lab you'll learn how to use both Docker and Docker Compose to build and run containers.

In this Lab scenario you'll work with 2 containers. A NGINX web server container which will be configured to proxy incoming HTTP requests downstream to second container running a customised Python FLASK based web application. The NGINX web server container will use the publicly available nginx:1.13.7 docker image. The FLASK based web application container will be based on a custom docker image that you will need to first create. 

This Lab will teach you how to use and define a Dockerfile to build a FLASK based web application, and then use it with the docker build command to build a Docker Image. You'll then learn how to use Docker Compose, a tool for defining and running multi-container Docker applications, to configure and launch the dual container (Nginx -> Flask) environment.

Learning Objectives

Upon completion of this Lab, you will be able to:

  • Edit and update a Dockerfile to create a Flask based web application
  • Use the docker build command to build a new Docker Image and tag it with cloudacademydevops/flaskapp:latest
  • Edit and update a Docker Compose file to create a dual container (Nginx -> Flask) setup
  • Use the docker-compose command to launch a dual container (Nginx -> Flask) setup
  • Test and validate the container setup using the curl command

You should:

  • Be comfortable with basic Linux command line administration
  • Be comfortable with basic container concepts

Lab Environment

This Lab will start with the following AWS resources provisioned automatically for you:

  • A single EC2 instance, named ide.containers.cloudacademy.platform.instance, which will have a public IP address attached. This will be the instance that you will connect to using your local workstation browser.

To achieve the Lab end state, you will be walked through the process of:

  • Using your local workstation browser to remotely connect to ide.containers.cloudacademy.platform.instance
  • Using the web based IDE and integrated terminal, you'll complete the remainder of the stated Lab Objectives (above)

Updates

December 28th, 2022 - Updated instructions with new commands

August 31st, 2021 - Update Dockerfile instruction to ensure the file is saved before attempting to build the image

August 14th, 2020 - Fixed issue preventing Kubernetes environment from starting

Covered topics

Lab steps

Connecting to the CloudAcademy Web based Containers IDE Port 8080
Complete a Dockerfile and Build an Image
Launch a New Docker Container and Test
Build and Test a Multi Container Setup Using Docker Compose