LAB
Note: This lab is based on Docker Tutorials and Labs.
Podeis utilizar Docker en vuestra maquina instalandolo siguendo las indicaciones que están aqui: https://docs.docker.com/get-docker/
O utilizar la maquina virtual que està en Poliformat/RSE: Recursos/Laboratorio/código practicas laboratorio
O online: https://labs.play-with-docker.com/#
All the code necessary for this Lab session is available in Poliformat/RSE: Recursos/Laboratorio/código practicas laboratorio, or here: https://bit.ly/codigoRSE2021
The goal of this block is to create a Docker image which will run a Flask app that displays a random pizza .gif
every time it is loaded.
We'll do this by first pulling together the components for a random pizza picture generator built with Python Flask, then dockerizing it by writing a Dockerfile. Finally, we'll build the image, and then run it.
We need the following three files:
app.py
templates/index.html
Dockerfile
The files can be found in the repository in POLIFORMAT as indicated above.
1.- Describe linea por linea el contenido del fichero Dockerfile
Apunta el resultado en el documento a entregar.
The docker build
command does the heavy-lifting of creating a docker image from a Dockerfile
.
When you run the docker build
command given below, make sure to replace <YOUR_USERNAME>
with your Docker username, the one you used when registering on Docker Hub. (If you havent registered yet… do it now.)
The docker build
command is quite simple - it takes an optional tag name with the -t
flag, and the location of the directory containing the Dockerfile
- the .
indicates the current directory:
the generated output should be something similar to:
If everything went well, your image should be ready! Run:
$ docker image ls
and see if your image (<YOUR_USERNAME>/myfirstapp
) shows.
The next step in this section is to run the image and see if it actually works.
2.- Explica cual es el suo del parametro -p 8888:5000
Apunta el resultado en el documento a entregar.
Open a browser with the URL http://localhost:8888
and your app should be live.
Hit the Refresh button in the web browser to see a few more pizza images.
Now that you've created and tested your image, you can push it to Docker Hub.
First you have to login to your Docker Cloud account, to do that:
Enter YOUR_USERNAME
and password
when prompted.
Now all you have to do is:
3.- Apunta el nombre completo de tu imagen en el documento a entregar.
4.- Tienes que crear el Dockerfile necesario para implementar un subscriber al broker broker.hivemq.com
para los mensajes con topic test/#
.
Como imagen base puedes utilizar alpine
y como codigo python base para el subscriber puedes reutilizar el sisub.py
de las sesiones de IoT .
Su ejecución tiene que dar algo asi:
En el documento a entregar tienes que adjuntar: