Skip to content

so0k/cacib-isap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Tech Talk Demo Script

This Repository contains the code I used for the live demonstration during the tech talk at Credit Agricole - Feb 27, 2016.

The code samples come from exising Docker labs material (see references below).

The slides are available as well

Docker CLI

Using Docker For Mac / Docker For Windows

docker pull alpine
docker image ls

Do this multipe times

docker run -it alpine /bin/sh
hostname
ps -a
ls -l
uptime

CTRL+D

docker run -it --rm busybox 

CTRL+D

docker run -d -p 80:80 --name webserver -v $PWD/static_site:/usr/share/nginx/html:ro nginx:alpine
docker stop webserver
docker rm webserver

Clean up containers

docker container prune
docker run -it --name test ubuntu:latest /bin/bash
apt-get install rolldice

CTRL+D

docker container ls -a
docker commit -t so0k:rolldice test

Instead, use a Dockerfile... static-site\Dockerfile

docker build -t so0k/static-site:latest .
docker run --name static-site -e AUTHOR="Docker Singapore" -d -p 80:80 so0k/static-site

CTRL+D

Docker Compose

Run a simple Flask app with a Redis cache.

cd counter/
docker-compose up

Change the code

vim app.py

Notice application code reloaded...

Another simple Python app (Master-Slave)

cd ../locust/
docker-compose up -d

Start the swarm

curl -XPOST http://127.0.0.1:8089/swarm -d"locust_count=20&hatch_rate=10"

Watch the status

watch -n 1 "curl -s http://127.0.0.1:8089/stats/requests | jq -r '[.user_count, .total_rps, .state] | @tsv'

Stop the swarm

curl http://127.0.0.1:8089/stop

Clean up

cd ../counter
docker-compose down --volume
cd ../locust
docker-compose down --volume

Using Docker-Machine:

  • Manage remote hosts
  • Provision multiple hosts locally
  • ..
docker-machine create --driver xhyve manager

Note: If network is a concern, do this in advance as well as

(cd vote;docker-compose pull)
docker-machine ls
docker-machine ssh manager
uname -a
docker-machine env manager
eval $(docker-machine env manager)
docker run -d --name static-site -e AUTHOR="Docker Singapore!" -d -p 80:80 so0k/static-site
docker-machine ip manager

open website on manager IP..

Notice also:

docker system info

Docker Swarm

Create a Swarm of Nodes

Create another node for the swarm

docker-machine create --driver xhyve worker
docker swarm init
eval $(docker-machine env worker)
docker swarm join \
     --token SWMTKN-?? \
     192.168.64.24:2377

Deploy Stack across swarm

Talk to manager

eval $(docker-machine env manager)
docker stack -h
cd vote/
docker-compose config | less
docker stack deploy -c docker-compose.yaml vote
docker service ls

Ports:

  • 8080 for node viz
  • 5000 for voting app
  • 5001 for result app

Clean up

docker stack rm vote
docker-machine rm manager worker

Unset docker environment:

eval $(docker-machine env -u)

References

About

Tech Talk for Credit Agricole

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published