-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurso_docker_2023.tex
More file actions
1418 lines (1153 loc) · 45.6 KB
/
curso_docker_2023.tex
File metadata and controls
1418 lines (1153 loc) · 45.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
a4paper,
DIV=11,
numbers=noendperiod,
onepage,
openany]{scrreprt}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage[lmargin=30mm,rmargin=30mm,tmargin=35mm,bmargin=30mm]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\KOMAoption{captions}{tableheading}
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\@ifpackageloaded{fontawesome5}{}{\usepackage{fontawesome5}}
\definecolor{quarto-callout-color}{HTML}{909090}
\definecolor{quarto-callout-note-color}{HTML}{0758E5}
\definecolor{quarto-callout-important-color}{HTML}{CC1914}
\definecolor{quarto-callout-warning-color}{HTML}{EB9113}
\definecolor{quarto-callout-tip-color}{HTML}{00A047}
\definecolor{quarto-callout-caution-color}{HTML}{FC5300}
\definecolor{quarto-callout-color-frame}{HTML}{acacac}
\definecolor{quarto-callout-note-color-frame}{HTML}{4582ec}
\definecolor{quarto-callout-important-color-frame}{HTML}{d9534f}
\definecolor{quarto-callout-warning-color-frame}{HTML}{f0ad4e}
\definecolor{quarto-callout-tip-color-frame}{HTML}{02b875}
\definecolor{quarto-callout-caution-color-frame}{HTML}{fd7e14}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{bookmark}{}{\usepackage{bookmark}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\makeatother
\makeatletter
\@ifundefined{shadecolor}{\definecolor{shadecolor}{rgb}{.97, .97, .97}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\makeatother
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={Docker 2023},
pdfauthor={Diego Saavedra},
colorlinks=true,
linkcolor={blue},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\title{Docker 2023}
\author{Diego Saavedra}
\date{Dec 4, 2023}
\begin{document}
\maketitle
\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[enhanced, boxrule=0pt, breakable, interior hidden, frame hidden, sharp corners, borderline west={3pt}{0pt}{shadecolor}]}{\end{tcolorbox}}\fi
\renewcommand*\contentsname{Table of contents}
{
\hypersetup{linkcolor=}
\setcounter{tocdepth}{2}
\tableofcontents
}
\bookmarksetup{startatroot}
\hypertarget{curso-de-docker}{%
\chapter{Curso de Docker}\label{curso-de-docker}}
¡Bienvenidos al Curso de Docker!
Este curso te guiará a través de un viaje desde los fundamentos hasta el
dominio de Docker, la plataforma de contenedores líder en la industria.
\hypertarget{quuxe9-es-este-curso}{%
\section{¿Qué es este Curso?}\label{quuxe9-es-este-curso}}
Este curso exhaustivo te llevará desde los conceptos básicos de Docker
hasta la implementación práctica de aplicaciones y servicios en
contenedores. A través de una combinación de teoría y ejercicios
prácticos, explorarás cada aspecto diseñado para fortalecer tus
habilidades en el uso de Docker. Desde la instalación inicial hasta la
orquestación de contenedores con Docker Compose, este curso te
proporcionará las herramientas y conocimientos necesarios para
desarrollar, desplegar y escalar aplicaciones con eficiencia.
\hypertarget{a-quiuxe9n-estuxe1-dirigido}{%
\section{¿A quién está dirigido?}\label{a-quiuxe9n-estuxe1-dirigido}}
Este curso está diseñado tanto para aquellos que están dando sus
primeros pasos en Docker como para aquellos que desean profundizar en
sus conocimientos. Ya seas un estudiante, un profesional en busca de
nuevas habilidades o alguien apasionado por la tecnología de
contenedores, este curso te brindará la base necesaria para trabajar de
manera efectiva con Docker en cualquier entorno.
\hypertarget{cuxf3mo-contribuir}{%
\section{¿Cómo contribuir?}\label{cuxf3mo-contribuir}}
Valoramos tu participación en este curso. Si encuentras errores, deseas
sugerir mejoras o agregar contenido adicional, ¡nos encantaría recibir
tus contribuciones! Puedes contribuir a través de nuestra plataforma en
línea, donde puedes compartir tus comentarios y sugerencias. Juntos,
podemos mejorar continuamente este recurso educativo para beneficiar a
la comunidad de usuarios de Docker.
Este curso ha sido creado con el objetivo de proporcionar acceso
gratuito y universal al conocimiento de Docker. Estará disponible en
línea para que cualquiera, sin importar su ubicación o circunstancias,
pueda acceder y aprender a su propio ritmo.
¡Esperamos que disfrutes este emocionante viaje de aprendizaje y
descubrimiento en el mundo de Docker y los contenedores!
\part{Curso Docker}
\hypertarget{comandos-buxe1sicos-y-atajos}{%
\chapter{1. Comandos Básicos y
Atajos}\label{comandos-buxe1sicos-y-atajos}}
\hypertarget{conceptos}{%
\section{Conceptos:}\label{conceptos}}
\textbf{Docker:} Es una plataforma para desarrollar, enviar y ejecutar
aplicaciones en contenedores. Un contenedor es una instancia ejecutable
de una imagen.
\textbf{Contenedor:} Es una instancia de una imagen que se ejecuta de
manera aislada. Los contenedores son ligeros y portátiles, ya que
incluyen todo lo necesario para ejecutar una aplicación, incluidas las
bibliotecas y las dependencias.
\hypertarget{ejemplos}{%
\section{Ejemplos:}\label{ejemplos}}
Descargar una imagen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ pull docker/getting{-}started}
\end{Highlighting}
\end{Shaded}
Este comando descarga la imagen \textbf{getting-started} desde el
registro público de Docker.
Correr un contenedor en el puerto 80:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}d} \AttributeTok{{-}p}\NormalTok{ 80:80 docker/getting{-}started}
\end{Highlighting}
\end{Shaded}
Este comando ejecuta un contenedor desenlazado en segundo plano (-d) y
mapea el puerto 80 de la máquina host al puerto 80 del contenedor (-p
80:80).
\hypertarget{pruxe1ctica}{%
\section{Práctica:}\label{pruxe1ctica}}
Descarga la imagen ``nginx'':
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ pull nginx}
\end{Highlighting}
\end{Shaded}
Descarga la imagen de Nginx desde el registro público.
Crea y ejecuta un contenedor en el puerto 8080:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}d} \AttributeTok{{-}p}\NormalTok{ 8080:80 nginx}
\end{Highlighting}
\end{Shaded}
\begin{itemize}
\tightlist
\item
Crea y ejecuta un contenedor de Nginx en el puerto 8080.
\item
Detén y elimina el contenedor creado:
\item
Utiliza los comandos para detener y eliminar un contenedor.
\end{itemize}
Resolución de la Actividad Práctica
Descarga la imagen de \textbf{Nginx}.
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ pull nginx}
\end{Highlighting}
\end{Shaded}
Crea y ejecuta un contenedor en el puerto 8080:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}d} \AttributeTok{{-}p}\NormalTok{ 8080:80 nginx}
\end{Highlighting}
\end{Shaded}
Detén y elimina el contenedor creado:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ stop }\VariableTok{$(}\ExtensionTok{docker}\NormalTok{ ps }\AttributeTok{{-}q}\VariableTok{)}
\ExtensionTok{docker}\NormalTok{ rm }\VariableTok{$(}\ExtensionTok{docker}\NormalTok{ ps }\AttributeTok{{-}a} \AttributeTok{{-}q}\VariableTok{)}
\end{Highlighting}
\end{Shaded}
\begin{tcolorbox}[enhanced jigsaw, opacityback=0, titlerule=0mm, bottomtitle=1mm, arc=.35mm, toptitle=1mm, breakable, colframe=quarto-callout-tip-color-frame, left=2mm, leftrule=.75mm, coltitle=black, rightrule=.15mm, toprule=.15mm, colbacktitle=quarto-callout-tip-color!10!white, colback=white, bottomrule=.15mm, title=\textcolor{quarto-callout-tip-color}{\faLightbulb}\hspace{0.5em}{Tip}, opacitybacktitle=0.6]
Combinar banderas mejora la eficiencia en la ejecución de comandos.
\end{tcolorbox}
\hypertarget{quuxe9-aprendimos}{%
\section{¿Qué Aprendimos?}\label{quuxe9-aprendimos}}
\begin{itemize}
\tightlist
\item
Aprendimos a descargar imágenes, correr contenedores y gestionarlos
básicamente.
\item
Entendimos la importancia de las banderas en los comandos Docker.
\end{itemize}
\hypertarget{actividad-pruxe1ctica}{%
\chapter{Actividad Práctica}\label{actividad-pruxe1ctica}}
\hypertarget{objetivo}{%
\section{Objetivo:}\label{objetivo}}
Familiarizarse con los comandos básicos de Docker y atajos para
gestionar contenedores de manera eficiente. Instrucciones:
\begin{itemize}
\tightlist
\item
Utilizando el comando docker run, inicia un contenedor de la imagen
``nginx'' en segundo plano, mapeando el puerto 8080 del host al puerto
80 del contenedor.
\item
Detén y elimina el contenedor recién creado utilizando comandos
Docker.
\item
Crea un nuevo contenedor con la imagen ``alpine'' y ejecuta un
terminal interactivo dentro de él.
\item
Desde el contenedor alpine, instala el paquete curl utilizando el
gestor de paquetes apk.
\item
Crea una imagen llamada ``alpine-curl'' a partir de este contenedor
modificado.
\end{itemize}
\hypertarget{entregables}{%
\section{Entregables:}\label{entregables}}
\begin{itemize}
\tightlist
\item
Documento explicando los comandos utilizados.
\item
Imagen Docker ``alpine-curl'' disponible localmente.
\end{itemize}
\hypertarget{rubrica-de-evaluaciuxf3n}{%
\section{Rubrica de Evaluación:}\label{rubrica-de-evaluaciuxf3n}}
\begin{itemize}
\tightlist
\item
Correcta ejecución de comandos: 6 puntos
\item
Clara documentación: 4 puntos
\item
Imagen ``alpine-curl'' creada correctamente: 10 puntos
\end{itemize}
Resolución de la Actividad Práctica
\begin{itemize}
\tightlist
\item
Iniciar un contenedor Nginx:
\end{itemize}
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}d} \AttributeTok{{-}p}\NormalTok{ 8080:80 }\AttributeTok{{-}{-}name}\NormalTok{ my{-}nginx nginx}
\end{Highlighting}
\end{Shaded}
Detener y eliminar el contenedor Nginx:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ stop my{-}nginx}
\ExtensionTok{docker}\NormalTok{ rm my{-}nginx}
\end{Highlighting}
\end{Shaded}
Crear un contenedor Alpine interactivo:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}it} \AttributeTok{{-}{-}name}\NormalTok{ my{-}alpine alpine /bin/sh}
\end{Highlighting}
\end{Shaded}
Instalar el paquete curl desde el contenedor Alpine:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{apk}\NormalTok{ add }\AttributeTok{{-}{-}no{-}cache}\NormalTok{ curl}
\end{Highlighting}
\end{Shaded}
Crear una nueva imagen ``alpine-curl'':
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ commit my{-}alpine alpine{-}curl}
\end{Highlighting}
\end{Shaded}
\hypertarget{trabajando-con-voluxfamenes}{%
\chapter{2: Trabajando con
Volúmenes}\label{trabajando-con-voluxfamenes}}
\hypertarget{conceptos-1}{%
\section{Conceptos:}\label{conceptos-1}}
\textbf{Volumes:} Son mecanismos que permiten persistir datos más allá
del ciclo de vida de un contenedor.
\hypertarget{ejemplos-1}{%
\section{Ejemplos:}\label{ejemplos-1}}
Crear un nuevo volumen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ volume create my\_volume}
\end{Highlighting}
\end{Shaded}
Este comando crea un volumen llamado ``my\_volume''.
Usar un volumen al correr un contenedor:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}v}\NormalTok{ my\_volume:/app }\AttributeTok{{-}d}\NormalTok{ node:18{-}alpine}
\end{Highlighting}
\end{Shaded}
Este comando ejecuta un contenedor de Node.js y vincula el volumen
``my\_volume'' al directorio ``/app'' dentro del contenedor.
\hypertarget{pruxe1ctica-1}{%
\section{Práctica:}\label{pruxe1ctica-1}}
\begin{itemize}
\tightlist
\item
Crea un volumen llamado \textbf{data\_volume}.
\item
Crea un volumen llamado \textbf{data\_volume}.
\item
Ejecuta un contenedor de MySQL, utilizando el volumen creado.
\end{itemize}
Resolución de la Actividad Práctica
Crea un volumen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ volume create data\_volume}
\end{Highlighting}
\end{Shaded}
Ejecuta el contenedor MySQL con el volumen creado:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}e}\NormalTok{ MYSQL\_ROOT\_PASSWORD=root }\AttributeTok{{-}e}\NormalTok{ MYSQL\_DATABASE=mydb }\AttributeTok{{-}v}\NormalTok{ data\_volume:/var/lib/mysql }\AttributeTok{{-}{-}network{-}alias}\NormalTok{ mysql }\AttributeTok{{-}d}\NormalTok{ mysql:latest}
\end{Highlighting}
\end{Shaded}
\begin{tcolorbox}[enhanced jigsaw, opacityback=0, titlerule=0mm, bottomtitle=1mm, arc=.35mm, toptitle=1mm, breakable, colframe=quarto-callout-tip-color-frame, left=2mm, leftrule=.75mm, coltitle=black, rightrule=.15mm, toprule=.15mm, colbacktitle=quarto-callout-tip-color!10!white, colback=white, bottomrule=.15mm, title=\textcolor{quarto-callout-tip-color}{\faLightbulb}\hspace{0.5em}{Tip}, opacitybacktitle=0.6]
\textbf{Recuerda la regla de oro:} Si dos contenedores están en la misma
red, podrán comunicarse.
\end{tcolorbox}
\hypertarget{quuxe9-aprendimos-1}{%
\section{¿Qué Aprendimos?}\label{quuxe9-aprendimos-1}}
\begin{itemize}
\tightlist
\item
Ahora entendemos cómo trabajar con volúmenes para mantener la
persistencia de datos en Docker.
\item
Aprendimos sobre Named Volumes y cómo vincularlos a contenedores.
\end{itemize}
\hypertarget{actividad-pruxe1ctica-1}{%
\chapter{Actividad Práctica}\label{actividad-pruxe1ctica-1}}
\hypertarget{objetivo-1}{%
\section{Objetivo:}\label{objetivo-1}}
Practicar el uso de volúmenes en Docker para persistir datos entre
contenedores.
\hypertarget{instrucciones}{%
\section{Instrucciones:}\label{instrucciones}}
\begin{itemize}
\tightlist
\item
Crea un nuevo volumen llamado ``mydata''.
\item
Inicia un contenedor de la imagen ``nginx'' y vincula el volumen
``mydata'' al directorio ``/usr/share/nginx/html'' dentro del
contenedor.
\item
Crea un archivo HTML dentro del volumen ``mydata'' con el mensaje
``Hola, este es un archivo HTML persistente''.
\item
Inicia otro contenedor de la imagen ``nginx'' y vincula el mismo
volumen ``mydata'' al directorio ``/usr/share/nginx/html'' dentro de
este segundo contenedor.
\item
Verifica que ambos contenedores comparten el mismo archivo HTML creado
en el paso 3.
\end{itemize}
\hypertarget{entregables-1}{%
\section{Entregables:}\label{entregables-1}}
\begin{itemize}
\tightlist
\item
Documento explicando los comandos utilizados.
\item
Capturas de pantalla que demuestren la persistencia de datos entre
contenedores.
\end{itemize}
\hypertarget{rubrica-de-evaluaciuxf3n-1}{%
\section{Rubrica de Evaluación:}\label{rubrica-de-evaluaciuxf3n-1}}
\begin{itemize}
\tightlist
\item
Correcta creación y vinculación de volúmenes: 6 puntos
\item
Creación y persistencia de archivos en el volumen: 8 puntos
\item
Verificación exitosa de la persistencia entre contenedores: 6 puntos
\end{itemize}
Resolución de la Actividad Práctica
Crear un nuevo volumen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ volume create mydata}
\end{Highlighting}
\end{Shaded}
Iniciar el primer contenedor Nginx con el volumen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}d} \AttributeTok{{-}p}\NormalTok{ 8080:80 }\AttributeTok{{-}{-}name}\NormalTok{ nginx{-}1 }\AttributeTok{{-}v}\NormalTok{ mydata:/usr/share/nginx/html nginx}
\end{Highlighting}
\end{Shaded}
Crear un archivo HTML dentro del volumen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ exec }\AttributeTok{{-}it}\NormalTok{ nginx{-}1 sh }\AttributeTok{{-}c} \StringTok{"echo \textquotesingle{}Hola, este es un archivo HTML persistente\textquotesingle{} \textgreater{} /usr/share/nginx/html/index.html"}
\end{Highlighting}
\end{Shaded}
Iniciar el segundo contenedor Nginx con el mismo volumen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ run }\AttributeTok{{-}d} \AttributeTok{{-}p}\NormalTok{ 8081:80 }\AttributeTok{{-}{-}name}\NormalTok{ nginx{-}2 }\AttributeTok{{-}v}\NormalTok{ mydata:/usr/share/nginx/html nginx}
\end{Highlighting}
\end{Shaded}
Verificar la persistencia del archivo HTML:
\begin{itemize}
\tightlist
\item
Acceder a \url{http://localhost:8080} en el navegador.
\item
Acceder a \url{http://localhost:8081} en el navegador.
\end{itemize}
\hypertarget{dockerfile-y-docker-compose}{%
\chapter{3: Dockerfile y Docker
Compose}\label{dockerfile-y-docker-compose}}
\hypertarget{conceptos-2}{%
\section{Conceptos:}\label{conceptos-2}}
\textbf{Dockerfile:} Es un archivo de texto que contiene instrucciones
para construir una imagen Docker. Es como un plano para la construcción
de imágenes.
\textbf{Docker Compose:} Es una herramienta que permite definir y
compartir aplicaciones multi-contenedor. Con un solo archivo
(docker-compose.yml), puedes configurar y ejecutar tus servicios.
\hypertarget{ejemplos-2}{%
\section{Ejemplos:}\label{ejemplos-2}}
\begin{itemize}
\tightlist
\item
Crear un Dockerfile para una aplicación Node.js:
\end{itemize}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{FROM}\NormalTok{ node:14}
\KeywordTok{WORKDIR}\NormalTok{ /app}
\KeywordTok{COPY}\NormalTok{ . .}
\KeywordTok{CMD}\NormalTok{ [}\StringTok{"npm"}\NormalTok{, }\StringTok{"start"}\NormalTok{]}
\end{Highlighting}
\end{Shaded}
Este Dockerfile configura una imagen de Node.js, establece el directorio
de trabajo, copia los archivos locales al contenedor y define el comando
para ejecutar la aplicación.
\begin{itemize}
\tightlist
\item
Configurar Docker Compose para una aplicación Node.js:
\end{itemize}
\begin{Shaded}
\begin{Highlighting}[]
\AttributeTok{ }\FunctionTok{version}\KeywordTok{:}\AttributeTok{ }\StringTok{\textquotesingle{}3\textquotesingle{}}
\AttributeTok{ }\FunctionTok{services}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{myapp}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{build}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{context}\KeywordTok{:}\AttributeTok{ .}
\AttributeTok{ }\FunctionTok{dockerfile}\KeywordTok{:}\AttributeTok{ Dockerfile.node}
\AttributeTok{ }\FunctionTok{image}\KeywordTok{:}\AttributeTok{ my{-}node{-}app}
\end{Highlighting}
\end{Shaded}
Este archivo docker-compose.yml define un servicio llamado ``myapp'' que
construirá una imagen usando el Dockerfile ``Dockerfile.node'' y le
asignará el nombre de ``my-node-app''.
\hypertarget{pruxe1ctica-2}{%
\section{Práctica:}\label{pruxe1ctica-2}}
\begin{itemize}
\item
Crea un Dockerfile para una aplicación Python simple:
\item
Configura un archivo docker-compose.yml para ejecutar la aplicación:
Resolución de la Actividad Práctica
\item
Ejemplo de Dockerfile (nombre: Dockerfile.python):
\end{itemize}
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{FROM}\NormalTok{ python:3.9}
\KeywordTok{WORKDIR}\NormalTok{ /app}
\KeywordTok{COPY}\NormalTok{ . .}
\KeywordTok{CMD}\NormalTok{ [}\StringTok{"python"}\NormalTok{, }\StringTok{"app.py"}\NormalTok{]}
\end{Highlighting}
\end{Shaded}
Ejemplo de docker-compose.yml:
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{version}\KeywordTok{:}\AttributeTok{ }\StringTok{\textquotesingle{}3\textquotesingle{}}
\FunctionTok{services}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{myapp}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{build}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{context}\KeywordTok{:}\AttributeTok{ .}
\AttributeTok{ }\FunctionTok{dockerfile}\KeywordTok{:}\AttributeTok{ Dockerfile.python}
\AttributeTok{ }\FunctionTok{image}\KeywordTok{:}\AttributeTok{ my{-}python{-}app}
\end{Highlighting}
\end{Shaded}
\begin{tcolorbox}[enhanced jigsaw, opacityback=0, titlerule=0mm, bottomtitle=1mm, arc=.35mm, toptitle=1mm, breakable, colframe=quarto-callout-tip-color-frame, left=2mm, leftrule=.75mm, coltitle=black, rightrule=.15mm, toprule=.15mm, colbacktitle=quarto-callout-tip-color!10!white, colback=white, bottomrule=.15mm, title=\textcolor{quarto-callout-tip-color}{\faLightbulb}\hspace{0.5em}{Tip}, opacitybacktitle=0.6]
Cuando trabajas con Docker Compose, es útil conocer el comando
docker-compose up con la opción -d para ejecutar los contenedores en
segundo plano. Esto permite liberar la terminal para otras operaciones
mientras tus servicios continúan ejecutándose en el fondo.
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker{-}compose}\NormalTok{ up }\AttributeTok{{-}d}
\end{Highlighting}
\end{Shaded}
Este comando es especialmente útil en entornos de desarrollo donde
deseas ejecutar múltiples servicios, pero aún así necesitas utilizar tu
terminal para otras tareas. Además, puedes detener los servicios en
segundo plano con:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker{-}compose}\NormalTok{ down}
\end{Highlighting}
\end{Shaded}
Esto ayudará a liberar los recursos utilizados por los contenedores sin
afectar tu entorno de desarrollo principal.
\end{tcolorbox}
\hypertarget{quuxe9-aprendimos-2}{%
\section{¿Qué Aprendimos?}\label{quuxe9-aprendimos-2}}
\begin{itemize}
\tightlist
\item
Hemos adquirido habilidades para crear imágenes personalizadas y
gestionar aplicaciones multi-contenedor con Docker Compose.
\item
Ahora comprendemos la importancia de organizar nuestras aplicaciones
en contenedores y cómo Docker Compose simplifica la orquestación.
\end{itemize}
\hypertarget{actividad-pruxe1ctica-2}{%
\chapter{Actividad Práctica}\label{actividad-pruxe1ctica-2}}
\hypertarget{objetivo-2}{%
\section{Objetivo:}\label{objetivo-2}}
Practicar la creación de imágenes personalizadas utilizando Dockerfile y
la orquestación de servicios con Docker Compose.
\hypertarget{instrucciones-1}{%
\section{Instrucciones:}\label{instrucciones-1}}
\begin{itemize}
\tightlist
\item
Crea un Dockerfile para una aplicación Python simple que imprima
``Hola, Docker'' al ejecutarse.
\item
Construye la imagen a partir del Dockerfile.
\item
Utilizando Docker Compose, define un servicio que utilice la imagen
creada y exponga el puerto 5000.
\item
Inicia el servicio con Docker Compose.
\item
Accede a la aplicación en \url{http://localhost:5000} y verifica que
imprime ``Hola, Docker''.
\end{itemize}
\hypertarget{entregables-2}{%
\section{Entregables:}\label{entregables-2}}
\begin{itemize}
\tightlist
\item
Dockerfile para la aplicación Python.
\item
Archivo Docker Compose.
\item
Documento explicando los comandos utilizados.
\item
Capturas de pantalla que demuestren el acceso a la aplicación.
\end{itemize}
\hypertarget{rubrica-de-evaluaciuxf3n-2}{%
\section{Rubrica de Evaluación:}\label{rubrica-de-evaluaciuxf3n-2}}
\begin{itemize}
\tightlist
\item
Correcta creación del Dockerfile: 6 puntos
\item
Imagen construida correctamente: 4 puntos
\item
Configuración adecuada en Docker Compose: 6 puntos
\item
Acceso exitoso a la aplicación: 4 puntos
\end{itemize}
Resolución de la Actividad Práctica
Dockerfile para la aplicación Python:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{FROM}\NormalTok{ python:3.9}
\KeywordTok{CMD}\NormalTok{ [}\StringTok{"python"}\NormalTok{, }\StringTok{"{-}c"}\NormalTok{, }\StringTok{"print(\textquotesingle{}Hola, Docker\textquotesingle{})"}\NormalTok{]}
\end{Highlighting}
\end{Shaded}
Construir la imagen:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker}\NormalTok{ build }\AttributeTok{{-}t}\NormalTok{ my{-}python{-}app .}
\end{Highlighting}
\end{Shaded}
Archivo Docker Compose (docker-compose.yml):
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{version}\KeywordTok{:}\AttributeTok{ }\StringTok{\textquotesingle{}3\textquotesingle{}}
\FunctionTok{services}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{myapp}\KeywordTok{:}
\AttributeTok{ }\FunctionTok{image}\KeywordTok{:}\AttributeTok{ my{-}python{-}app}
\AttributeTok{ }\FunctionTok{ports}\KeywordTok{:}
\AttributeTok{ }\KeywordTok{{-}}\AttributeTok{ }\StringTok{"5000:5000"}
\end{Highlighting}
\end{Shaded}
Iniciar el servicio con Docker Compose:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{docker{-}compose}\NormalTok{ up }\AttributeTok{{-}d}
\end{Highlighting}
\end{Shaded}
Verificar el acceso a la aplicación:
Acceder a \url{http://localhost:5000} en el navegador.
\hypertarget{buenas-pruxe1cticas-y-seguridad}{%
\chapter{4: Buenas Prácticas y
Seguridad}\label{buenas-pruxe1cticas-y-seguridad}}
\hypertarget{conceptos-3}{%
\section{Conceptos:}\label{conceptos-3}}
\textbf{Escaneo de imagen:} Después de construir una imagen, es buena
práctica realizar un escaneo en busca de vulnerabilidades.
\textbf{Capas de la imagen:} Cada imagen de Docker se construye en
capas, permitiendo un nivel de abstracción independiente.
\textbf{Multi-Stage builds:} Permiten separar dependencias necesarias
para construir la aplicación de las necesarias para ejecutarla en
producción, reduciendo el tamaño de la imagen final.
\hypertarget{ejemplos-3}{%
\section{Ejemplos:}\label{ejemplos-3}}
Escaneo de imagen con Snyk:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{snyk}\NormalTok{ container test }\OperatorTok{\textless{}}\NormalTok{IMAGE\_NAME:TAG}\OperatorTok{\textgreater{}}
\end{Highlighting}
\end{Shaded}
Utilizando la herramienta Snyk, podemos escanear una imagen en busca de
vulnerabilidades.
Uso de Multi-Stage builds:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{FROM}\NormalTok{ node:14 }\KeywordTok{AS}\NormalTok{ builder}
\KeywordTok{WORKDIR}\NormalTok{ /app}
\KeywordTok{COPY}\NormalTok{ . .}
\KeywordTok{RUN} \ExtensionTok{npm}\NormalTok{ install}
\KeywordTok{RUN} \ExtensionTok{npm}\NormalTok{ run build}
\KeywordTok{FROM}\NormalTok{ nginx:alpine}
\KeywordTok{COPY} \OperatorTok{{-}{-}from=builder}\NormalTok{ /app/dist /usr/share/nginx/html}
\end{Highlighting}
\end{Shaded}
Este Dockerfile utiliza Multi-Stage builds para primero construir una
aplicación Node.js y luego copiar solo los artefactos necesarios en una
imagen más ligera de Nginx.
\hypertarget{pruxe1ctica-3}{%
\section{Práctica:}\label{pruxe1ctica-3}}
\begin{itemize}
\tightlist
\item
Realiza un escaneo de vulnerabilidades en una imagen de tu elección:
\item
Utiliza Snyk para escanear una imagen de Docker.
\item
Implementa un Multi-Stage build en un Dockerfile:
\end{itemize}
Resolución de la Actividad Práctica
Escaneo de imagen con Snyk:
\begin{Shaded}
\begin{Highlighting}[]
\ExtensionTok{snyk}\NormalTok{ container test my{-}image:my{-}tag}
\end{Highlighting}
\end{Shaded}
Ejemplo de Multi-Stage Dockerfile:
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{FROM}\NormalTok{ node:14 }\KeywordTok{AS}\NormalTok{ builder}