Differences

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

Link to this comparison view

rl:labs:11:contents:01 [2020/11/15 20:17]
jan.vaduva [00. [0p] Play With Docker]
rl:labs:11:contents:01 [2024/01/08 12:29] (current)
vlad_iulius.nastase [01. [0p] Definere proiect]
Line 1: Line 1:
-==== 00. [0p] Play With Docker ​====+==== 01. [0p] Definere proiect ​====
  
-Play With Docker (PWD) este un mediu online dedicat invatarii si testarii docker. Ofera masini virtuale gratuit in limita a 4h / sesiune.+Din stanga sus, de lângă logo-ul Google Cloud se poate fie selecta proiectul de lucru, fie crea un nou proiect
  
-Este nevoie sa intrati ​pe linkul https://​labs.play-with-docker.com/​ si sa va autentificati folosind contul vostru ​de **Dockerhub** https://​hub.docker.com/+Dacă cream un nou proiect (apăsăm ​pe butonul aferent), pagina pentru proiect nou va fi deschisă pe ecran de unde putem seta numele proiectului și organizația la care este asociat
  
-{{:​rl:​labs:​11:​contents:​play-with-docker.png?​200|}} +Pentru ​acest laboratorne vom folosi ​de proiectul ​**upb-retele-locale-2024** prin contul oferit ​de catre asistent.
- +
-“Login” (with docker account) -> “Start” +
-  +
-Pentru ​inceputadaugati o **singura instanta** +
- +
-{{:​rl:​labs:​11:​contents:​play-with-docker-instance.png?​200|}} +
- +
-<​note>​Este posibil sa aveti probleme de afisaj daca nu tineti fereastra in modul “Maximised”</​note>​ +
- +
-Dupa ce ati lansat o instanta, va trebui sa fiti direct conectati la noua instanta. +
- +
-{{:​rl:​labs:​11:​contents:​play-with-docker-console.png?​200|}} +
- +
-Instanta ruleaza pe o distributie ​de **Alpine Linux**, dedicata rularii docker si a comenzilor de retea din linux (precum iptables). +
- +
-Pentru a accesa public o aplicatie care ruleaza in **PWD** (play with docker) este nevoie sa apasati pe portul expus. +
- +
-{{:​rl:​labs:​11:​contents:​play-with-docker-web.png?​200|}} +
- +
-**PWD** va face un tunel public pentru a expune public portul. +
- +
- +
- +
-==== 01. [20p] Hello Docker ==== +
- +
-Docker este un runtime ​de containerizare modern, care aduce în componența sa uneltele necesare împachetării unei aplicații, și a dependințelor acesteia, într-un obiect numit container. Asemănător LXC, Docker utilizează mecanismele native din Kernel-ul sistemului de operare care permit rularea izolată a unei aplicații, fără ca aceasta să interacționeze sau să influențeze procesele sistemului gazdă sau procesele aflate în execuție în alte containere. Dintr-o perspectivă mai pragmatică,​ putem considera un container ca fiind o multiplicare a user-space-ului (terminologia utilizată în sistemelor de operare monolitice) +
-<​note>​ +
-Dacă nu înțelegeți încă această ultimă sintagmă... SO is coming! +
-</​note>​ +
- +
-Ca în orice început din IT, vom porni cu Hello, world! +
-<code bash> +
-student@aldebaran:​~$ docker run hello-world +
-Unable to find image '​hello-world:​latest'​ locally +
-latest: Pulling from library/​hello-world +
-1b930d010525:​ Pull complete +
-Digest: sha256:​4df8ca8a7e309c256d60d7971ea14c27672fc0d10c5f303856d7bc48f8cc17ff +
-Status: Downloaded newer image for hello-world:​latest +
- +
-Hello from Docker! +
-This message shows that your installation appears to be working correctly. +
- +
-To generate this message, Docker took the following steps: +
- 1. The Docker client contacted the Docker daemon. +
- 2. The Docker daemon pulled the "​hello-world"​ image from the Docker Hub. +
-    (amd64) +
- 3. The Docker daemon created a new container from that image which runs the +
-    executable that produces the output you are currently reading. +
- 4. The Docker daemon streamed that output to the Docker client, which sent it +
-    to your terminal. +
- +
-To try something more ambitious, you can run an Ubuntu container with: +
- $ docker run -it ubuntu bash +
- +
-Share images, automate workflows, and more with a free Docker ID: +
- ​https://​hub.docker.com/​ +
- +
-For more examples and ideas, visit: +
- ​https://​docs.docker.com/​get-started/​ +
-</​code>​ +
- +
-Să verificăm ce se întâmplă. Pentru a vedea containerele care sunt în running state:  +
-<code bash> +
-student@aldebaran:​~$ docker ps +
-CONTAINER ID        IMAGE               ​COMMAND ​            ​CREATED ​            ​STATUS ​             PORTS               ​NAMES +
-</​code>​ +
- +
-Lista este goală. Pentru a vedea toate containerele,​ atât cele în running state cât și cele oprite: +
-<code bash> +
-student@aldebaran:​~$ docker ps -a +
-CONTAINER ID        IMAGE               ​COMMAND ​            ​CREATED ​            ​STATUS ​                    ​PORTS ​              ​NAMES +
-4bedb1ae0304 ​       hello-world ​        "/​hello" ​           4 minutes ago       ​Exited (0) 4 minutes ago                       ​vibrant_wu +
-</​code>​ +
- +
-**Voila!** +
- +
-Să încercăm să rulăm un container de Alpine Linux, una din distribuțiile lightweight de Linux existente. +
-<code bash> +
-student@aldebaran:​~$ docker run alpine +
-Unable to find image '​alpine:​latest'​ locally +
-latest: Pulling from library/​alpine +
-89d9c30c1d48:​ Pull complete +
-Digest: sha256:​c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a +
-Status: Downloaded newer image for alpine:​latest +
-student@aldebaran:​~$ docker ps +
-CONTAINER ID        IMAGE               ​COMMAND ​            ​CREATED ​            ​STATUS ​             PORTS               ​NAMES +
-student@aldebaran:​~$ docker ps -a +
-CONTAINER ID        IMAGE               ​COMMAND ​            ​CREATED ​            ​STATUS ​                     PORTS               ​NAMES +
-7e1f217f73d4 ​       alpine ​             "/​bin/​sh" ​          38 seconds ago      Exited (0) 35 seconds ago                       ​cool_cray +
-4bedb1ae0304 ​       hello-world ​        "/​hello" ​           6 minutes ago       ​Exited (0) 6 minutes ago                        vibrant_wu +
-</​code>​ +
- +
-Container-ul este oprit. Motivul pentru care se întâmplă acest lucru se datorează faptului că ciclul de viață al unui container este 1 la 1 cu ciclul de viață al aplicației care rulează în acel container. Astfel, în cazul în care aplicația își finalizează execuția, container-ul aferent își va încheia și el rularea. Pentru a vedea ce proces rulează în mod implicit în container putem folosi docker inspect: ''​docker inspect <nume sau id container>''​ +
- +
-Pentru simplitate, putem obține informația căutată utilizând filtre (%%--format%%):​ +
-''​docker inspect <nume sau id container>​ %%--format='​{{.Config.Cmd}}%%'''​+
  
 <note tip> <note tip>
-Pentru a forța execuția continuă a containerului,​ putem utiliza argumentele -dit +Dacă nu vă apare proiectul în listă, încercați să îl căutați folosind numele proiectului ​(''​upb-retele-locale-2024''​).
-(referințe suplimentare în pagina de manual [[http://​manpages.ubuntu.com/​manpages/​bionic/​man1/​docker-run.1.html|docker-run]]) +
-  * -d detach +
-  * -i interactive +
-  * -t pseudo-tty+
 </​note>​ </​note>​
- 
-<code bash> 
-student@aldebaran:​~$ docker run -dit --name infinite-alpine alpine 
-b3bbcf9fcd8c265cf96e50c885c10ff68b597e4ba987f7e78630c094432f14bc 
-</​code>​ 
- 
-Putem schimba, totodată, comanda care rulează în container: 
-<code bash>​docker run -dit --name sleep-alpine alpine sleep 10000</​code>​ 
- 
-Și putem atașa sesiunea curentă de shell unui container aflat în execuție: 
-<code bash> 
-student@aldebaran:​~$ docker exec -it infinite-alpine /bin/sh 
-/ # ls 
-bin    dev    etc    home   ​lib ​   media  mnt    opt    proc   ​root ​  ​run ​   sbin   ​srv ​   sys    tmp    usr    var 
-</​code>​ 
- 
-<note important>​Afișați pe rând: 
-  * pid-ul utilizatorului curent: ''​id''​ 
-  * adresa ip a containerului:​ ''​ip a''​ 
-  * toate procesele care rulează pe sistem: ''​ps -ef''​ sau ''​ps aux''​ 
-  * hostname-ul:​ ''​hostname''​ 
-  * variabilele de mediu: ''​env''​ 
-  * și ieșiți: ''​exit''​ 
-</​note>​ 
- 
-În continuare vom vorbi despre conceptul de Docker Images. 
- 
rl/labs/11/contents/01.1605464273.txt.gz · Last modified: 2020/11/15 20:17 by jan.vaduva
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0