< Previous Solution - Home - Next Solution >
This is PATH A: Use this path if your students want to understand what’s involved in creating a Docker container, and understand basic docker commands. In this path, your students will create a Dockerfile, build and test local containers, and then push these container images to Azure Container Registry.
NOTE: Before the hack, it is the Coach’s responsibility to download and package up the contents of the /Student/Resources folder of this hack into a Resources.zip file. The coach should then provide a copy of the Resources.zip file to all students at the start of the hack. The student guide refers to relative path locations within this zip package.
The students can either work with Docker locally on their workstation or they can deploy a build machine VM in Azure using the provided template. There is no need to do both. We recommend using the build VM deployed in Azure as this provides a known-to-work common environment.
# Bash Script
RG="akshack-RG" #Change as appropriate
LOCATION="EastUS" # Change as appropriate
az group create --name $RG --location $LOCATION
az deployment group create --name buildvmdeployment -g $RG \
-f docker-build-machine-vm.json \
-p docker-build-machine-vm.parameters.json
# Powershell Script
$RG="akshack-RG" #Change as appropriate
$LOCATION="EastUS" # Change as appropriate
az group create --name $RG --location $LOCATION
az deployment group create --name buildvmdeployment -g $RG `
-f docker-build-machine-vm.json `
-p docker-build-machine-vm.parameters.json
ssh -p 2266 wthadmin@12.12.12.12One of the tasks in this challenge is, prior to building the docker images, is to run the application locally. In many cases, the coach may simply want to demonstrate this for the students rather than having them each do this individually. To run the Fab Medical application locally:
npm installnode ./server.js &http://localhost:3001/speakersCONTENT_API_URL that points to the API app’s URL.http://localhost:3001localhost only works when both apps are run locally using Node. You will need a different value for the environment variable when running in Docker.ps command to list all processes running, and then the Linux kill command to kill the two Node.js processes./Coach/Solutions folder for Challenge 1. These files are also located in the /Challenge-02 folder of the Resources.zip package the students have, but they shouldn’t know that at this point unless you tell them.
docker build –t content-api .docker build –t content-web .docker network create fabmedicaldocker run -d -p 3001:3001 --name api --net fabmedical content-apidocker run -d -p 3000:3000 --name web --net fabmedical content-web--name parameter of the docker run command for content-api will be the DNS name for that container on the docker network. Therefore, the value of the CONTENT_API_URL environment variable in the content-web Dockerfile should match it.docker ps
docker rm
- removes/deletes an imagedocker kill
- kills a containerdocker image list
- lists all images on the machinedocker image prune
- kills all dangling imagessudo netstat -at | less is useful to see what ports are running. This may help students with troubleshooting.