Using a Dockerfile and Docker-Compose to Build and Run Containers
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
October 24th, 2024 - Resolved an issue preventing the lab from provisioning successfully
December 28th, 2022 - Updated instructions with new commands
August 14th, 2020 - Fixed issue preventing Kubernetes environment from starting