Daniel Hagimont firstname.lastname@example.org
The goal of this labwork is to discover Docker and to automate the deployment/undeployment of an architecture composed of several tomcat/servlets behind a HAProxy load balancer.
You must be connected to N7 with the VPN and be connected to a N7 machine with your studenID. Use the following commands to access your server :
Type your enseeiht password.
Where XX=01-40. This will give you acces to a VM with IP address 192.168.27.(XX+10) and the password is "toto"
Docker installation with a simple command
Test your installation
Download a Ubuntu image from the hub
We will use this image in the following. List the images you have locally, each image has a name, tag and ID
You can remove an image with
you can start a container with
Type « exit » to exit from a container
you can list all your containers (from another terminal) with
and get containerIDs. To restart a container use :
To connect back to a container console do
You can customize your container
Then, save an image of the container (from another terminal) with
You can stop your container (from another terminal) with
You can remove your container (from another terminal) with
For all these commands, you can use names or IDs as well
You can create a Docker image by describing it in a Dockerfile. In a directory "tomcat", create a file Dockerfile.
You have to download the Hello.war which is a little webapp
start-tc.sh is a script for starting tomcat .
Add Hello.war and start-tc.sh in the tomcat directory.
You can then build the container image with the following command (in the tomcat directory)
You can start an instance of this image.
You can get the IP address from the container with:
docker inspect conainerID
You can access the webapp with the URL
The figure presents the target architecture (final goal).
Create two containers
HAProxy is configured by a file
haprox_backup.cfg is a template of that file (given) where you can add lines
server server1 <ip-of-tomcat>:8080 maxconn 32
you can test that it works with one HAProxy and one Tomcat. You can implement a script which creates these two images Start the Haproxy container
Test your configuration with
create a script which deploys an architecture with one HAProxy and 2 Tomcat
You can create a network (bridge) for your instances
You can start your Tomcat instances in that network with
You can add you Tomcat instances in the HAProxy configuration file with
You can start a HAProxy instance which mounts a configuration file (haprox.cfg) which is local to the host system.
Reproduce the previous architecture using docker compose
Create the docker-compose.yml file (you can start from this content)