User Tools

Site Tools


tanszek:oktatas:iss_t:docker

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tanszek:oktatas:iss_t:docker [2023/04/02 16:56] – létrehozva kneheztanszek:oktatas:iss_t:docker [2024/03/25 08:25] (current) knehez
Line 1: Line 1:
 ==== Docker Virtualization in practice ==== ==== Docker Virtualization in practice ====
  
-In the following, we will see how the popular Docker virtualization/containers can be used in practice.+We will see how the popular Docker virtualization/containers can be used in practice.
  
-Please log in at http://docker.iit.uni-miskolc.hu/ . Then click the green start button.+Please log in at http://docker.iit.uni-miskolc.hu/ . Then click the green start button. (if does not work please use the official version: https://labs.play-with-docker.com/ )
  
 After pressing the "+ Add new instance" button on the left side, we will see the following screen: After pressing the "+ Add new instance" button on the left side, we will see the following screen:
Line 92: Line 92:
   * EXPOSE command opens a tcp port to the outside (in this case, 5000)   * EXPOSE command opens a tcp port to the outside (in this case, 5000)
   * copy everything to the working directory   * copy everything to the working directory
-the last line defines the startup command after installation, in this case: "flask run"+  * the last line defines the startup command after installation, in this case: "flask run"
  
-Soronként következőket definiáljuk:+==== Creating docker-compose file to manage lifecycle ====
  
-  * Hozzon létre egy kiinduló virtuális gépet (image) a python 3.7-es támogatással és a **alpine** nevű linux kernellel. +In other tutorials, the virtual machine is started at this pointWe don't do it, but move on to the possibilities of **docker-compose.yml**, which allows us to flexibly manage several virtual machines at the same timeIt is not necessary to create Dockerfile eitherif we use standard configurations available on the Internet.
-  a munkakönyvtárunk a /code lesz. +
-  Állítsunk be két környezeti változótami a flask-nak szükséges a kiszolgáláshoz. +
-  * Telepítsük gcc-t és más függőségeket. (ez azért kellmert a Python sok csomagot c/c++ forrás állományokból fordít) +
-  * másoljuk be a requirements.txt-t a munkakönyvtárba (ez azért kell, mert a virtuális gépnek saját fájlrendszere van, a Dockerfile mellett lévő állományokat nem tudja közvetlenül olvasni.) +
-  * EXPOSE parancs tcp portot nyit meg kifelé (jelen esetben az 5000-est) +
-  * mindent másoljuk be a munkakönyvtárba +
-  * az utolsó sor a telepítés utáni indító parancsot definiálja, jelen esetben: "flask run"+
  
- +Create the docker-compose.yml file as usual:
- +
-==== Compose állomány létrehozása ==== +
- +
-Más leírásokban ennél a pontnál elindítják a virtuális gépet. Mi nem tesszük meg, hanem továbblépünk a **docker-compose** lehetőségeire, amivel rugalmasan tudunk több virtuális gépet egyszerre kezelni. Nem feltétlenül kell Dockerfile-t sem létrehozni, ha Interneten is elérhető szabványos konfigurációkat használunk. +
- +
-Hozzuk létre a docker-compose.yml állományt a szokásos módon:+
  
 <code> <code>
Line 124: Line 111:
 </code> </code>
  
-Ez az állomány szolgáltatásokban gondolkodik. Minden **service** egy különálló docker image, viszont a nevükre hivatkozva belsőleg elérik egymástA fenti konfiguráció **web** elnevezésű szolgáltatását a **build: .** miatt a Dockerfile alapján hozzuk létreviszont a másik **redis** szolgáltatást a szabványos "redis:alpine" konfiguráció alapján használjuk+Each //service// is a separate docker image, but they reach each other internally by referring to their namesThe service named //web// in the above configuration is provided by //build: .// because of this, we create it based on the //Dockerfile//but we use the other redis service based on the standard "redis:alpine" configuration.
  
-A **web** esetén a belsőleg kinyitott 5000-es portot láthatóvá tesszük a 80-as port-on.+In the case of the //web//, the internally opened port 5000 is made visible on port 80.
  
-Indítsuk el a következő parancsot és várjuk meg ameddig lefut:+Let's start the following command and wait until it runs:
  
 <code> <code>
Line 134: Line 121:
 </code> </code>
  
-A következő képernyőhöz hasonlót kell látnunkha mindent jól állítottunk be előzőleg. Nyomjuk meg a nyíllal jelölt gombot.+We should see something similar to the next screenif everything was set up correctly previously.
  
 {{tanszek:oktatas:informatikai_rendszerek_epitese:3.png?320x200|}} {{tanszek:oktatas:informatikai_rendszerek_epitese:3.png?320x200|}}
  
  
 +==== Possibilities for development ====
  
-==== Fejlesztési lehetőségek ====+Refresh the browser several times, we can see that the number of visits is updated dynamically.
  
-Frissítsük többször a böngészőt, láthatjuk, hogy a látogatásszám dinamikusan frissül.+Ctrl + c can be used to stop the execution.
  
-Ctrl + c segítségével megállíthatjuk a futtatást. +replace the contents of //docker-compose.yml// with the following:
- +
-cseréljük le a docker-compose.yml tartalmát a következőre:+
  
 <code> <code>
Line 163: Line 149:
 </code> </code>
  
-**volumes** beállítjahogy a virtuális gépben belül levő könyvtár, jelen esetben a __working directory__ a gazda rendszerhez legyen kötveilletve kimásolvaHa nem a gyökérbe szeretnénk mappelniakkor pl: ./mycode:/code is megadhatóde a mycode könyvtárnak az indítás előtt léteznie kell.+**volumes** sets the directory inside the virtual machinein this case the working directory ./ is connected to the host system. (it meansall the file changes will shared between the host and container.) If you don't want to map to the rootyou can enter e.g.: ./mycode:/code, but the **mycode** directory must exist before starting.
  
-Indítsuk el újra a rendszert:+Let's restart the system:
  
 <code> <code>
Line 171: Line 157:
 </code> </code>
  
-Majd látható, hogy a konzolban developer módra kapcsoltunkMódosítsuk az editor segítségével a app.py-tmondjuk az utolsó függvényben a kiírás szövegét és frissítsük a böngészőt.+Then you can see that we switched to developer mode in the consoleUse the editor to modify //app.py//, say the text of the statement in the last functionand update the browser.
  
  
-==== Docker compose parancsok ====+==== Docker compose commands ====
  
-Futó virtuális gépek listázása:+List running virtual machines::
  
 <code> <code>
Line 182: Line 168:
 </code> </code>
  
-Egy adott instance milyen környezeti változókat használ?+What environment variables does a given instance use?
  
 <code> <code>
Line 188: Line 174:
 </code> </code>
  
-Hogyan állíthatjuk le a szolgáltatásokat?+How can we stop the services?
  
 <code> <code>
-docker-compose stop+docker-compose stop <service-name>
 </code> </code>
  
-Hogyan tudunk teljesen letörölni mindent leállítás után?+How can we completely wipe everything after shutdown?
  
 <code> <code>
Line 200: Line 186:
 </code> </code>
  
-Hogyan tudunk shellbe belépni egy konténeren belül?+How can we enter a shell inside a container?
  
 <code> <code>
Line 206: Line 192:
 </code> </code>
  
-Honnan tudok előre elkészített minta container-eket letölteni?+How can I see the logs? 
 +<code> 
 +docker-compose logs <containername> 
 +</code> 
 + 
 + 
 +Where can I download pre-made sample containers?
  
 https://github.com/docker/awesome-compose https://github.com/docker/awesome-compose
  
 +Source code can be found here: https://github.com/knehez/isi in folder example_1.
  
  
  
  
tanszek/oktatas/iss_t/docker.1680454606.txt.gz · Last modified: 2023/04/02 16:56 by knehez