Pulling and running a docker container using the Docker CLI and the Python SDK. All commands should be run in the command line.
docker run -p 8080:8080 -d --name primecheck --rm nclcloudcomputing/javabenchmarkapp # Pull and run the web app
open http://localhost:8080/primecheck # Check the app is working
python task-01.py # Pull and run the web app
Deploying a multi-service application with 2 replications of a prime number check, a MongoDB database and a swarm visualiser
docker swarm init # Initialse swarm
docker stack deploy -c docker-compose.yml cloudproject # Deploy services
docker service ls # Show services
docker container ls -a # Show containers
open http://localhost:88 # Check they are running
open http://localhost:80/primecheck
open http://localhost:3306
docker stack rm cloudproject # Remove stack
docker swarm leave --force # Leave swarm
python task-02-deploy.py # deploy app
python task-02-display.py # displaying services and container ids
open http://localhost:8081 # Check they are running
open http://localhost:8080/primecheck
open http://localhost:3306
python task-02-leave.py # leave swarm
This calls the prime number check URL placing a load on the web application. Allowing system benchmarking.
sh ./task-03-load-generator.sh http://localhost:8080/primecheck 4 2 4
This section adds a Docker monitoring tool, cAdvisor.
Run when stack is deployed
docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=70:8080 --detach=true --rm --name cadvisor google/cadvisor:latest --storage_duration=2m0s --allow_dynamic_housekeeping=false --housekeeping_interval=1s
python task-04-cadvisor.py # run cadvisor
Check it is working
open http://localhost:70
sh ./task-03-load-generator.sh http://localhost:80/primecheck 3 5 5 # run the load gen and observe changes
Open terminals side by side. Note, the mongoDB has been mounted on the host machine working directory
Here you can whats going on in the database
docker exec -it 6d8e17481bed mongo # access mongo interactive shell
show dbs # show databases
use project # switch to project database
show collections # show collections
This places the load and stores the results
sh ./task-05-master.sh http://localhost:8080/primecheck 150 10 1 four # placing load on web app and storing data
Running this script recreates plot, memory or cpu usage, in cAdvisor using the data stored in the mongoDB Prerequisites:
graphics/
folder in working directory, graphics are saved here.collection.csv
created during Task 4databases-names.csv
created during Task 4
Rscript R/graphs.R <absolute path to R script directory> <metric> # format
Rscript R/graphs.R /Users/jackwaudby/Library/'Mobile Documents'/com~apple~CloudDocs/csc8110/docker/R memory #example