Skip to content

Commit

Permalink
Add exercices
Browse files Browse the repository at this point in the history
  • Loading branch information
fjammes committed Nov 15, 2016
1 parent ec5a327 commit 1b5dc1f
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions courses/1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Slides: http://pointful.github.io/docker-intro/#/
File renamed without changes.
23 changes: 23 additions & 0 deletions courses/3/resources/10-containers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# cat /proc/meminfo

serverCount=10
startDate=$(date)
for n in $(seq 1 1 $serverCount)
do
hostPort=$(($n + 10000))
provider="World #$n"
echo "Starting $n. Host Port: $hostPort, Message: $provider"
docker run -d -p $hostPort:5000 -e "PROVIDER=$provider" training/webapp
done
echo
echo Started $n containers. Start time: $startDate, end time: $(date)

# Stop all: docker stop $(docker ps -q)
# Remove all stopped: docker rm $(docker ps -aq)

# Test run:
# free –m: 1494
# 1 Container: 1480
# 100 Containers: 124
33 changes: 33 additions & 0 deletions courses/3/resources/ex2/webserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# A Dockerfile is a simple text-file that contains a list of commands
# that the Docker client calls while creating an image.
# It's a simple way to automate the image creation process.
# The best part is that the commands you write in a Dockerfile are almost
# identical to their equivalent Linux commands. This means you don't really
# have to learn new syntax to create your own dockerfiles.

# Use ubuntu as base image, it will be downloaded automatically
FROM ubuntu:latest
MAINTAINER Jacques Celere "jacques.celere@gmail.com"

# Update and install python-3
RUN xxxx

# Create /home/www
RUN xxxx

# Set /home/www as WORKDIR
WORKDIR xxxx

# Copy index.html inside container, in /home/www
# NOTE: code could also be retrieved from git repository
ADD xxxx

# Copy hello.py inside container, in /home/src
# NOTE: putting this command to the last line
# would allow to rebuild only this layer if if hello.py is changed
ADD xxxx

# Launch /home/src/hello.py at container startup
# It will serve files located where it has been launch
CMD xxxx

11 changes: 11 additions & 0 deletions courses/3/resources/ex2/webserver/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import http.server
import socketserver

PORT = 8000

Handler = http.server.SimpleHTTPRequestHandler

httpd = socketserver.TCPServer(("", PORT), Handler)

print("serving at port", PORT)
httpd.serve_forever()
1 change: 1 addition & 0 deletions courses/3/resources/ex2/webserver/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
1 change: 1 addition & 0 deletions courses/3/resources/ex2/www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, I'm on host machine!
File renamed without changes.

0 comments on commit 1b5dc1f

Please sign in to comment.