├── LICENSE ├── day-01.md ├── day-02.md ├── day-03.md ├── day-04.md ├── day-05.md ├── day-06.md ├── day-07.md ├── day-08.md ├── day-09.md ├── day-10.md ├── day-11.md ├── day-12.md ├── day-13.md ├── day-14.md ├── day-15.md ├── day-16.md ├── day-17.md ├── day-18.md ├── day-19.md ├── day-20.md ├── day-21.md ├── day-22.md ├── day-23.md ├── day-24.md ├── day-25.md ├── day-26.md ├── day-27.md ├── day-28.md ├── day-29.md ├── day-30.md └── images ├── docker-ps-filtering.png ├── docker-ps-formatting.png ├── layers.jpg ├── lifecycle.jpg ├── oci-image-1.jpg ├── oci-image-2.jpg └── terminal.jpg /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /day-01.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 1 2 | 3 |
4 | إيلا بغيتي تجبد آخر Containers صايبتي (docker create/run) ممكن تستعمل l- و n- ديال Docker ps .. 5 | ممكن تخدم هاذ اللعيبة باش تمسح container لي صايبتي مأخرا: 6 |
7 | 8 |
    9 |
  • باش تمسح آخر container :
  • 10 |
11 | 12 | $ docker rm $(docker ps -ql) 13 | 14 |
    15 |
  • باش تمسح آخر خمسة containers :
  • 16 |
17 | 18 | $ docker rm $(docker ps -qn 5) 19 | 20 | >
ملاحظة : docker ps -q باش تخرّج غير IDs ديال containers
-------------------------------------------------------------------------------- /day-02.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 2 2 | 3 |
4 | في نفس السياق ديال docker ps، ايلا الفورما output ديال docker ps ماعجبكش ممكن تبدلو باستعمال format-- .
5 | هاذ اللعيبة تاتنفع في Debugging باش تشوف المعلومات لي عندك بيهم غرض فقط . 6 | و خاصة في reports فين ممكن تجبد اللائحة ديالة containers بواحد الفورما معينة (فيها غير ذاكشي لي تايهم الفريق ديالك(ولا الكليان)، و تزيدها في report و تسيفطو ليهم. 7 |
8 | 9 |
    10 |
  • باش تجبد الأسماء و CMD لي تإكزيكيتات ديال جميع container على شكل table :
  • 11 |
12 | 13 | $ docker ps -a --no-trunc --format="table {{.Names}}\t{{.Command}}" 14 | 15 |
    16 |
  • باش تجبد اللائحة ديال containers و ports ديالهم على وديت شي رابور :
  • 17 |
18 | 19 | $ docker ps --format="- Container {{.Names}} with ID {{.ID}} is running on those ports {{.Ports}}" >> report.md 20 | 21 | --- 22 |
ملاحظات: 23 |
    24 |
  • الكومند docker ps -a باش تجبد جميع containers حتى لي ماشي running
  • 25 |
  • ايلا كانت شي معلومة طويلة docker ps تاتاخد غير واحد العدد ديال الحروف و تاتدير truncate لداكي لي بقى و ايلا بغينا نمنعوها من هاذشي، يعني بغينا المحتوى كامل تانستعملوا no-trunc--
  • 26 |
  • اذيك << باش نزيدو المحتوى ديال docker ps في report في اللخر
  • 27 |
  • هاذ format-- تاتخدم Go template syntax
  • 28 |
  • في التصويرة كاين شنو ممكن نجبدو بالضبط من format--
  • 29 |
30 |

31 | 32 | --format 33 | 34 |

35 |
-------------------------------------------------------------------------------- /day-03.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 3 2 | 3 |
4 | في نفس السياق ديال docker ps عاوتاني، ممكن تفيلتري المحتوى ديال docker ps بلا grep بلا والو غير ب filter-- .
5 | هاذ اللعيبة تاتنفع عاوتاني في Debugging و حتى منين تاتبغي تمسح container لي مابقيتيش بغيتيهم و ممكن تخدمها مع format-- . 6 |
7 | 8 |
    9 |
  • شي مرات تاتطلع ليك شي error و تاتبقى تصايب بزاف ديال containers باش تحاول تحلها، و منين تاتسالي و تايخدم ذاكشي تاتلقى بزاف ديال containers ماعندك ماتدير بيهم .. يكفي أنك تعرف الأول لي صايبتي و تخلي كلشي ل filter--
  • 10 |
11 | 12 | $ docker rm -f $(docker ps -aq --filter="since=66bf51ac5a4b") 13 | 14 |
    15 |
  • ايلا صايبنا شي image سميناها DevC لي تاتexecute commands معينين، و بغينا نعرفو containers لي كراشاو بسبب أن الكومند غالطة يعني error code = 127
  • 16 |
17 | 18 | $ docker ps -a -f "exited=127" -f="ancestor=DevC" --format "{{.ID}} {{.Command}}" 19 | 20 | --- 21 |
ملاحظات: 22 |
    23 |
  • التصويرة فيها الفلترز لي ممكن نستعملوهم
  • 24 |
25 |

26 | 27 | filters 28 | 29 |

30 |
-------------------------------------------------------------------------------- /day-04.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 4 2 | 3 |
4 | آخر لعيبة على الفيلترز و ذاكشي .. هاذاكشي ديال فيلترز و فورما ماكاينش غير في docker ps، كاين حتى بالنسبة لimages.
5 | كاين شي اختلافات و لكن قليلة، و هذا واحد منها
6 | ال dangling images هو واحد النوع في شكل images لي غالبا غادي تكون فايت شايفهم (هاذوك لي سميتهم None و لي شادين ليسباص بلا سبب) .
7 | الfilter-- ديال docker images تاتعطينا الامكانية أننا نجبدو هاذ الimages 8 |
9 | 10 |
    11 |
  • ايلا بغيتي تمسح جميع dangling image و تخوي شوية السطوكاج
  • 12 |
13 | 14 | $ docker rmi -f $(docker images -qf "dangling=true") 15 | 16 | --- 17 |
ملاحظات: 18 |
    19 |
  • ماشي جميع images لي سميتهم none تايكونو dangling و تايكونوا بدون فائدة .
  • 20 |
  • منين تاتدير build أو pull لشي image عندك أصلا و بنفس tag . تايمشي docker يحيد للقديمة tag باش يطاكّي الجديدة، وهنا فين تايخرجو dangling images
  • 21 |
22 |
-------------------------------------------------------------------------------- /day-05.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 5 2 | 3 |
4 | شفنا قبل كيفاش نجبدوا المعلومات باستعمال docker ps و docker images عاوتاني .. اليوم غادي نشوفوا طريقة أقوى باش نجبدوا معلومات أكثر على containers و images لي هي docker inspect لي كاتعطي جميع المعلومات تقريبا .
5 | لي زوين في docker inspect هي أنها by default تاتعطي النتيجة على شكل json لي ممكن تبارسيه Parse و تجبد لي بغيتي . 6 |
7 | 8 |
    9 |
  • باش نجبدوا المعلومات على image ديالنا DevC:rabat و تخبيهم في json file
  • 10 |
11 | 12 | $ docker inspect --type image DevC:rabat > DevC.json 13 | 14 |
    15 |
  • باش نجبدوا معلومات علىnetworking ديال container ديالنا و نديروه في الرابور لي غانصيفطو لSRE باش يشوف شنو المشكل
  • 16 |
17 | 18 | $ echo -e "\`\`\`json\n$(docker inspect devC | jq '.[0].NetworkSettings')\n\`\`\`" > report.md 19 | 20 |
    21 |
  • باش نحضيو capabilities ديال containers .. و نكتبوا شي حاجة ايلا شي حاجة ماشي هي هاذيك
  • 22 |
23 | 24 | $ docker inspect 86e2d8181c53 | jq -r '.[0].EffectiveCaps' | grep -i DAC_OVERRIDE > /dev/null && echo "Fin awa ghaadi ?" 25 | --- 26 |
ملاحظات: 27 |
    28 |
  • بالنسبة type-- تاتنفع منين تايكون عندك container و image بنفس الاسم.
  • 29 |
  • بالنسبة للبارسين parsing ممكن تديرو بلغة البرمجة ديالك أو بjq لي هو CLI tool ساهل و سريع 😃
  • 30 |
  • النتيجة ديال docker inspect تاتكون على شكل array
  • 31 |
32 |
-------------------------------------------------------------------------------- /day-06.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 6 2 | 3 |
4 | غادي ناخدوا استراحة من commands و نهضروا على كيفاش containers يقدروا يسهلوا علينا شي حوايج لي ممكن يكونوا شوية معنكشين .
5 | مثلا ايلا بغيتي تدوز requests ديالك من Tor Network و تحس براسك آنونيموس بكل سهولة 😁 ، ممكن تدير هاذشي بكل بساطة باستعمال واحد community image سميتها dperson/torproxy لي مقادة باش تدير هاذشي 6 |
7 | 8 |
    9 |
  • أولا جبد public ip address ديالك
  • 10 |
11 | 12 | $ curl ifconfig.me 13 | 14 |
    15 |
  • من بعد صايب كونتينر ديال torproxy
  • 16 |
17 | 18 | $ sudo docker run -it -p 8118:8118 -p 9050:9050 -d dperson/torproxy 19 | 20 |
    21 |
  • عاود جبد public ip address ديالك، ولكن هاذ المرة مور البروكسي .. تاداااا 🎉
  • 22 |
23 | 24 | $ curl -x 127.0.0.1:8118 ifconfig.me -------------------------------------------------------------------------------- /day-07.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 7 2 | 3 |
4 | هاذ النهار غادي نهضروا على Dockerfiles لي هوما files لي تايكون فيهم المراحل لي غادي نتبعوا باش غادي نبنيو image ديالنا منين غادي نعيطوا على docker build
5 | خلال البناء build كانحتاجوا نكوبييو شي ملفاتfiles ديالنا لimage .. و باش نديرو هاذشي كاينين 2 طرق COPY و ADD .. و الفرق هو أن ADD ذكية شوية على COPY: 6 |
7 | 8 |
    9 |
  • بالنسبة ل COPY تاتكوبيي لينا الملفات (مثلا الكون ديل آبليكاسيون) لي عطيناها من الحاسوب ديالنا Host، للimage لداخل .. و فقط ماتازيد والو من راسها.
    10 | المثال الجاي غادي يكوبيي devC من الحاسوب ديالنا ل/app لداخل في image
  • 11 |
12 | 13 | COPY ./devC /app 14 | 15 |
    16 |
  • أما ADD فهي شوية ذكية، بحيث أنها تاتقدر تعرف النوع ديال source و تتعامل معاه على حساب .. ADD تاتقدر تكوبيي ملفات عادي بحال COPY زائد URLs أو Archive ليتدير ليهم extract أوتوماتيكيا.
  • 17 |
18 | 19 | # the archive will be extracted into /app 20 | COPY devC.tar.gz /app 21 | # download the files into /app 22 | ADD devcrabat.com/code.tar /app 23 | 24 | --- 25 |
ملاحظات: 26 |
    27 |
  • ممكن تبان ليك ADD أحسن في جميع الحالات و لكن بالعكس منين تبغي تكوبي الملفات ديالك ديما استعمل COPY الا ايلا كنتي محتاج ADD بالصح. السبب هو أن COPY is explicit يعني تاتكون عارف شنو غاجي يوقع مسبقا، في حين ADD تقدر خاصك تحضي راسك لاتمشي تدير شي حاجة بلا ماترد ليها البال، مثلا نتى محتاج تكوبي tar هو النيت، و لكن ADD تExtractih
  • 28 |
  • غادي نبدل التوقيت ديال البوستس، ل بوسط كل يومين باش تبقى لي الفرصة نحط حوايج آخرين.
  • 29 |
  • هاذ اليامات كانوجد واحد البروجي صغير، كنت بديتو شحال هاذي و من بعد كّيكّس بلابلا لي فاتت، قررت نرجع نكملو.
  • 30 |
31 |
32 | -------------------------------------------------------------------------------- /day-08.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 8 2 | 3 |
4 | كمالة على ذاكشي ديال COPY و ADD .
5 | بزاف ديال المرات تانكونوا بغينا نكوبييو شي ملفات وبغيناهم يبانو بشي USER:GROUP معينين و هنا كاينين حلول لي بديهية 6 |
7 | 8 | # Solution 1 9 | COPY ./devC /app 10 | RUN chmod devc:devc 11 | # Solution 2 12 | USER devc:devc 13 | 14 | 15 | 16 | COPY ./devC /app 17 | 18 |
19 | هاذ الحلول خدامة و لكن ماشي optimal خاصة الأول و غادي تزيد الحجم و الشكل ديال image ديالنا شوية .
20 | الحل هو نستعملوا غير COPY 21 |
22 | 23 | COPY --chown devc:devc ./devC /app -------------------------------------------------------------------------------- /day-09.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 9 2 | 3 |
4 | كيفما قلنا قبل، عموما كلما كان عدد commands في Dockerfile كلما أحسن، و السبب أن images تايكونوا على شكل طبقات layers و كل طبقة تاتكون النتيجة ديال شي command
5 | في هاذ القضية كاينين 2 أنواع ديال Commands .. الcommands لي تايبدلو شي حاجة في Filesystem بحال RUN و COPY و هاذو تايخلقوا طبقات عندها حجم و الcommands لي تايبدلوا غير في Metadata بحال EXPOSE و ENTRYPOINT
6 | باش نجبدو الطبقات لي كاينين في شي image و الحجم ديالهم و شنو command لي خلقاتهم كانستعملوا docker history 7 |
8 | 9 | $ docker history devC:latest 10 | 11 | --- 12 |
ملاحظات: 13 |
    14 |
  • كيفاش تايخبي Docker الimages و كيفاش تاتعامل معاهم فيه بزاف مايتقال و ماكرهتش نديرو ليه شي حاجة بوحدو
  • 15 |
  • كاينين أدوات ديال كوميونيتي لي تايعطيو معلومات أكثر على الimages بحال Dive
  • 16 |
17 |
-------------------------------------------------------------------------------- /day-10.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 10 2 | 3 |
4 | دائما مع Dockerfiles .. كاينين 3 ديال Commands لي لي تايمكنونا نexecutew commands، لي هوما RUN و CMD و ENTRYPOINT . 5 |
6 | 7 |
    8 |
  • بالنسية لRUN الCommand تاتexecuta وسط الimage براسها، يعني منين تاندير docker build .
  • 9 |
10 | 11 | # dockerfile 12 | ... 13 | RUN apt-get update && apt-get install curl 14 | ... 15 | # --- 16 | 17 | 18 | 19 | # this will be executed when we'll call this 20 | $ docker build -t devc:rabat . 21 | 22 |
    23 |
  • بالنسبة لCMD و ENTRYPOINT تايexecutaw منين تانرانيو container ديالنا. يعني Docker run
  • 24 |
25 | 26 | # dockerfile 27 | ... 28 | CMD curl Devc.com 29 | ... 30 | # --- 31 | 32 | 33 | # this will be executed when we'll call this 34 | $ docker run devc:rabat 35 | 36 |
37 | حاجة أخرى مهمة هي أنن هاذ الكوماندس ممكن ياخدو 2 أشكال 38 |
    39 |
  • الEXEC Form و هنا تانعطيو الbinary لي بغينا نexecutew مع باراميترز ديالو على شكل array و docker تايمشي يقلب في الPATH و تايقضي الغرض
  • 40 |
41 |
42 | 43 | # dockerfile 44 | ... 45 | RUN ["apt", "install", "-y", "curl"] 46 | CMD ["/bin/curl", "https://devc.com"] 47 | ... 48 | 49 |
50 |
    51 |
  • الSHELL form لي تانعطيو فيها commands لي بغينا على شكل string هاذ المرة و Docker تايدوزهم للشيل الشهير sh باش يexecutehom
  • 52 |
53 | هاذ الثانية تاتنفعنا ايلا بغينا نستعملو شي خاصيات ديال الشيل بحال && و || و pipes .... 54 |
55 | 56 | # dockerfile 57 | ... 58 | RUN apt install -y curl 59 | # is equivalent to 60 | CMD ["/bin/sh", "-c", "apt install -y curl"] 61 | 62 | 63 | --- 64 |
ملاحظات: 65 |
    66 |
  • بالنسبة لshell form، في حالة CMD أو ENTRYPOINT الpid 1 تايكون هو sh و هاذشي لي تايمنعنا من أننا نتواصلو مع الexecutable ديالنا مباشرة باستعمال Unix Signals يعني ايلا كان عندك شي program تاي...handle CTRL+C or CTRL+Z بشي طريقة في شكل من الأحسن تستعمل EXEC form .. حيت في هاذ الحالة غادي يكون sh حاجز بينك و بين البروكّرام ديالك و هو لي غادي يتكلف ب signals.
  • 67 |
  • كاين فرق بين CMD و ENTRYPOINT غادي نهضرو عليه المرة الجاية
  • 68 |
69 |
-------------------------------------------------------------------------------- /day-11.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 11 2 | 3 |
4 | اليوم غادي نهضروا على CMD و ENTRYPOINT .. هاذ الموضوع فلسفي و أزلي في Docker و متلف العالم كامل و منهم أنا ..
5 | عموما منين تانbuild'ew شي container image تانكونوا أمام 2 ديال الخيارات .. 6 |
7 | 8 |
    9 |
  • الاول هو أن الimage تاتكون عبارة عن package للآبليكاسيون ديالنا .. يعني تانوجدو كّاع ذاكشي لي خاص الآبليكاسيون باش تخدم في runtime و تانقولو لDocker أنها Runnable و كيفاش غادي يrunيها.
    10 | هنا تانستعملوا Docker من اجل Packaging يعني في آخر المطاف هاذيك Image غادي هي الطريقة الكافية باش أي واحد يخدم الأبليكاسيون ديالنا (Process)
    11 | في هاذ الحالة كايخاصنا نقولو لDocker منين يجي image ديالنا، يعني شناهو الProcess لي تايشكل الهوية ديال أبليكاسيون ديالنا. و هذا هو entrypoint ديال image ديالنا.
    12 | هاذا هو الusecase الأكثر شيوعا ديال docker و images في هاذ السياق هوما images ديال أبليكاسيونات ديالنا لي تانصايبو. 13 |
  • 14 |
15 | 16 |
    17 |
  • الخيار الثاني هو تانستعملو docker باش نصايبو واحد الوسط مناسب (يعني فيه libs و dependencies لي بغينا) فين نrun'ew شي commands و شي Applications ديالنا.
    18 | هنا كانهضرو على images بحال ديال gnu/linux distro ولا ديال programming ecosystems بحال python أو node.js ....
    19 | في هاذ الحالة image ديالنا ماتاتكونش مراد منها تكون package و لكن تاتكون ecosystem .. و هاذشي لي تايخليها ماتايكونش عندها Entrypoint واحد مفروض على user في runtime .. و لكن بالعكس تايكون مطلوب منها تكون قادرة تexecute واحد العدد ديال commands aka CMD
    20 | في هاذ الUsecase تايكون ممكن لينا نحددوا CMD في الBuild و لكن ماتاتكونش مفروضة علينا في الRun و تايمكن لينا نبدلوها بسهولة
    21 | دابا من بعد ما هضرنا على ENTRYPOINT و CMD و الفرق بيناتهم و Motivation ديال كل واحدة .. آجي نشوفو كيفاش نخدموهم.
    22 | عمليا، ENTRYPOINT و CMD عندهم نفس المفعول في أغلب الحالات.. الفرق هو أن CMD ممكن تبدلوها بcommand لي بغينا في Runtime 23 |
  • 24 |
25 | 26 | # dockerfile 27 | ... 28 | ENTRYPOINT ["node", "devc.rabat.js"] 29 | ... 30 | # --- 31 | 32 | # this will run the devc rabat node application. 33 | docker run -it devc:rabat 34 | 35 |
36 | نفس المثال بCMD 37 |
38 | 39 | # dockerfile 40 | ... 41 | CMD ["node", "devc.rabat.js"] 42 | ... 43 | # --- 44 | 45 | # this will run the devc rabat node application. 46 | docker run -it devc:rabat 47 | # but this will run the devc casa node application. 48 | docker run -it node devc.casa.js 49 | 50 |
51 | واحد من usecases الزوينين لCMD هو نستعملوها باش ندوزو Parameters لENTRYPOINT ديالنا مادام المحتوى ديال CMD دائما تايتزاد في الأخير (هاذ اللعيبة تاتخدم في Exec form فقط) 52 |
53 | 54 | # dockerfile 55 | ... 56 | CMD ["--help"] 57 | ENTRYPOINT ["node", "devc.js"] 58 | ... 59 | # --- 60 | 61 | # this will display the help message for our app 62 | docker run -it devc:rabat 63 | # this will run our app with awesome argument. 64 | docker run -it devc:rabat awesome 65 | 66 | --- 67 |
ملاحظات: 68 |
    69 |
  • حتى ENTRYPOINT ممكن نبدلوه في Runtime باستعمال entrypoint-- و لكن غير منصوح بيها حيث غانكون تانبدلو الهوية ديال container بحد ذاتها
  • 70 |
  • كنت بغيت نهضر على One process per container Philosophy و كيفاش تاتأثر في Design ديال Dockerfiles و CMD و ENTRYPOINT و لكن تايبان لي غادي نخليوها لمرة أخرى
  • 71 |
72 |
-------------------------------------------------------------------------------- /day-12.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 12 2 | 3 |
4 | اليوم غادي نكملو على نفس الأفكار ديال الايام ليدازو و غادي نهضرو على واحد القاعدة مهمة ديال Docker لي هي One Process per container ..
5 | واخا تاتبان بسيطة، هاذ القاعدة ضروري نكونوا فاهمينها باش نطيحوش في مشاكل من بعد .. 6 |
7 | 8 |
9 | بما أن Docker is a process container system يعني أنه تايهمتم بprocess واحد و تاrun'eh بواحد الطريقة لي تاتخليه معزول على البقية ديال processes عكس Machine container systems بحال LXC مثلا لي مديوريين باش يتكلفو بuse cases فين ماينين Processes بزاف.. 10 |
11 | 12 |
13 | أهم حاجة هنا هي process واحد .. docker دائما تايفترض أنه مخدم غير process واحد هو لي تايكون في CMD أو ENTRYPOINT (لي شفناهم المرة لي فاتت) و لي تايكون عندو PID1 .. 14 |
15 | 16 |
17 | من بعد Docker تايبقى على تواصل مع هاذ الprocess دائما باستعمال IPC signals لي باستعمالهم تايعرف واش باقي حي و ليبيهم تايقتلو ايلا بغا ..
18 | هاذ المبدأ يقدر يبان لينا بايخ و ماشي مهم، و لكن مهم بزاف .. 19 |
20 | 21 |
22 | نفترض أننا في ENTRYPOINT تانطلبو من Docker يخدم لينا واحد Shell script لي براسو تايخدم بزاف ديال programs مثلا nginx و php-fpm و شي php scripts لي تايديرو شي حاجة .. 23 |
24 | 25 | #!/bin/bash 26 | nginx & 27 | php-fpm & 28 | php ./debugging.php & 29 | php ./observability.php & 30 | --- 31 | # Dockerfile 32 | ENTRYPOINT ["script.sh"]t 33 | 34 |
35 | في الحالة العادية، ايلا مات شي واحد من هاذ الprograms غادي نبغيو docker يعرف، و ياخد القرار ولا يسيفط المعلومة لشي بلاصة (لkubernetes مثلا) .. و لكن ماشي هاذشي لي غادي يوقع حيت docker ما عندو تاشي علاقة بهاذ الprograms و تايعرف غير مول PID1 لي هو shell ديالنا bash أو sh 36 |
37 | 38 | docker exec -it devC bash 39 | pkill nginx 40 | 41 | # Nothing will happen, 42 | # the container will still be up an running 43 | 44 | kill 1 # which will kill /bin/bash 45 | # This will code the container to exit 46 | 47 |
48 | في هاذ الحالة الحل هو نطوروا ذاك الscript ديالنا باش يتكلف ب Error handling و يصيفط signals لDocker ما ان طرى شي حاجة لشي process أو نستعملو شي program لي متخصص في process management بحالsupervisor أو dumb-init 49 |
-------------------------------------------------------------------------------- /day-13.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 13 2 | 3 |
4 | ايلا كنتي تاتخدم بdocker ضروري غادي تتعامل بزاف مع Shell خاصة في Dockerfiles .. اليوم غادي نشوفو واحدالمجموعة ديال القوالب و النصائح لي عندهم علاقة بShell و لي ممكن ينفعونا منين نكونو تانكتبو dockerfiles ديالنا 5 |
6 | 7 |
    8 |
  • موما منين تايعيطو على شي program وسط الshell script ديالنا أو منين تانخدموا أي program في Linux .. تايطرى واحد البلان سميتو fork يعني أن kernel تايدير نسخة من process اﻷب (لي هو shell في الحالة ديالنا) و من بعد تايدير exec لي تاتشد الprogram ديالنا و تاتخشيه في هاديك النسخة الجديدة ديال الأب ..
    9 | طريقة أخرى باش نصايبو process جديد هي نحرقو المراحل و مانعيطوش على fork و ندوزو نيشان من exec ..يعني أننا غادي نشدو program ديالنا و غادي نخشيوه وسط الأب براسو.
  • 10 | أبسط مثال على هاذشي هو ps:
    11 |
      12 |
13 | 14 | # here we'll get two processes the parent(shell) and child (ps) 15 | ps > processes.txt 16 | # Here we'll only get one process (ps). 17 | exec ps > processes.txt 18 | 19 |
20 |
    21 | هاذ اللعيبة (exec) لي هي shell wrapper over exec syscalls تاتفعنى منين تانخدمو Shell form في ENTRYPOINT أو CMD و تاتخلينا نبدلة process ديال الshell بالprocess ديال الprogram ديالنا و نتهناو من ديك الوصاية ديال shell لي هضرنا عليها في البوسط لي فات. 22 |
  • 23 | اللعيبة الثانية لي غادي نهضرو عليها هي set -euo pipefail .. من الحوايج الصعابين في shell scripting هو error handling .. شي مرات تاتكون الerror في الشرق و الميساج في الغرب ..هاذ الكومند غادي تعاونا نردو scripts ديالنا أفضل من ناحية error handling 24 |
  • 25 |
  • 26 | الe- : عموما واخا يكون سكريبت ديالنا فيه شي مشكل .. الshell تايكمل بحال ايلا ماكاين والو حتى الآخر .. هاذ e- تاتقول لshell يخرج ايلا شي كومند exit code ديالها ماكانش 0 27 |
  • 28 |
  • 29 | ال o pipefail- : ايلا كان الscript ديالنا فيه شي pipeline يعني هاذي | 😁 .. e- ماتانفعش بزاف بحيث أنها تاتشوف exit code ديال pipeline كاملة يعني ديال آخر كومند في pipeline فقط .. و هاذ pipefail تاتحل لينا هاذ المشكل و تاتبزز على shell يخرج ايلا لقى شي كومند في pipe ماخدماش.. 30 |
  • 31 |
  • 32 | ال-u: هاذي عاوتاني مهمة بزاف .. عموما الshell ماعندوش مشكل مع empty variables باستعمال هاذ option ممكن نقولو ليه بي ايلا استعملنا شي variables خاوية را كاين مشكل. 33 |
  • 34 |
  • 35 | اللعيبة الثالثة هي Debugging ..ال set -x تاتقول لshell يكتب أي كومند قبل ما يexecute'ha هاكا تانعرفو فين كاين المشطل ايلا كان 36 |
  • 37 | 38 |
-------------------------------------------------------------------------------- /day-14.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 14 2 | 3 |
4 | البوسط لي داز كان على shell scripting و شي حوايج لي ممكن ينفعونا نكتبوا Dockerfiles ديالنا .. هاذ البوسط غادي يكون كمالة على ذاكشي لي كنا بدينا .. 5 |
6 | 7 |
    8 | اليوم غادي نهضرو على Filename Expansion و Docker و واحد الحاجة مهمة لي كاتستعمل بزاف في dockerfiles و ماهضرناش عليها المرة لي دازت و لي هي shopt -s nullglob 9 |
10 | 11 |
    12 | الposix shells فيهم واحد الخاصية سميتها Filename Expansion و هي منين تانعطيوه شي filename و تانعطيوه وسط منو واحد من [ ] أو * أو ? تاحاول يستعملهم باش يجبد filenames كاميلين مثلا 13 |
14 | 15 | # this will delete all pdf file in the working directory 16 | rm *.pdf 17 | # This will remove mp3, mp4 and any files ending with "mp" followed by a character 18 | rm *.mp? 19 | # this will remove all files starting with a, n or k 20 | rm [akn]* 21 | 22 |
23 | في حالة ايلا shell ماقدرش يدير expansion تايدوز هاذيك glob كيفما هي للcommand و هاذشي لي تايعطينا error على حساب command لي استعملنا.
24 | اش نفهموا أكثر آجي نتخيلو واحد function تانعطيوها واحد المجموعة ديال files و هي تاتدير عليهم شي خدمة.
25 | المشكل ايلا دوزنا ليها شي glob لي ماتاتماتشي والو غادي يدوزها هاكاك و هاذشي يقدر يعطينا شي حاجات ماشي هي هاذيك.
26 | باش نحلو هاذ المشكل انستعملو nullglob لي في حالة الglob ماماتشات والو تاترد لينا empty string "" 27 |
28 | 29 | 30 | # if we execute this statement 31 | myfunction *.pdf 32 | ## if there are pdf files in cwd the shell will execute this 33 | ## > myfuction 1.pdf 2.pdf book.pdf 34 | ## if there are no pdf files 35 | ## > myfunction "*.pdf" 36 | ## Since there is no file named "*.pdf" our function will file (a lot of times silently) 37 | ## if nullglob is on 38 | ## > myfunction "" 39 | 40 |
41 | ممكن نستعملو failglob لي تاتحبس الscript ايلا كان شي مشكل و لكن عموما هاذا هو التصرف الاعتيادي ايلا كنا خدامين ب set -e 42 |
-------------------------------------------------------------------------------- /day-15.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 15 2 | 3 |
4 | هذا غادي يكون آخر بوسط على shell scripting
5 | في الأول كنت بغيت ندير بوسط على expansions و لكن لقيت بلي غادي يخاص بزاف ديال الكتابة داكشي علاش غادي نحاول نهضر اليوم على substring expansion فقط لي مفيدة بزاف .. 6 | 7 |
8 | 9 |
10 | قبل مانعرف substring expansion فينما كنت تانبغي نخدم على شي حاجة لي تاتحتاج بزاف ديال string manipulation تانفكل مباشرة في python (أي high level scripting language قاضي الغرض) .. و لكن دابا وليتا تانخدم غير بBash صافي..
11 | الsyntax ساهلة {param:offset:limit}$
12 | بحيث أن param هي variable ديالنا (shell parameters مفهموم أشمل في shells تايضم حتى الvariables) و الoffset هو منين بغينا نبداو slice و limit هو عدد الcharacter لي بغينا ناخدو .. 13 |
14 | 15 | a="DevC Rabat" 16 | echo ${a} # basic param expansion 17 | echo ${a:5} # >> Rabat 18 | echo ${a:0:4} # >> DevC 19 | echo "${a:5} ${a:0:4}" >> Rabat DevC 20 | 21 | --- 22 |
ملاحظات: 23 |
    24 |
  • هاذ القضية تاتنفع بزاف في scripts ديالنا ولكن المشكل ديالها هو أنها ماشي POSIX يعني ماكايناش في sh و هاذشي علاش خاص نردو معاها البال في Dockerfiles و ENTRYPOINT و نسبقوها ب bash -c أو نزيدو Shebang الفوق فيها bash ايلا كان سكريبت ..
  • 25 |
26 |
-------------------------------------------------------------------------------- /day-16.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 16 2 | 3 |
4 | اليوم غادي نهضرو على واحد command مامشهوراش بزااف و لكن مهمة بزاف خاصة في debugging و في long running containers ..
5 | الكومند هي docker diff .. هاذ الكوموند تاترد لينا التغييرات لي طراو في container ديالنا منين تcrea'ya .. 6 |
7 | 8 | docker exec -it DevC bash 9 | touch /app/docker.md 10 | rm /app/text.txt 11 | cat "hello" >> /app/devc.txt 12 | # Results 13 | C /app 14 | A /app/docker.md 15 | D /app/text.txt 16 | C /app/devc.txt 17 | 18 |
19 | كيفما تانشوفو الoutput تايكون على شكل file path و حداهم على اليمين إما C (Changed) أو A)added) أو D)Deleted) 20 |
-------------------------------------------------------------------------------- /day-17.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 17 2 | 3 |
4 | اليوم غادي نهضروا على أكثر على Docker Images و على كيفاش نكتبوا Dockerfiles أحسن ..
5 | باش يstore'e الimages ديالنا Docker تايعتامد على Storage Drivers لي تايخزنوهم على شكل Layers في Filesystem ديالنا .. 6 | فاش كانكونوا خدامين على Dockerfile منين تانديرو شي command بحال COPY أو ADD أو RUN تاتصايب Layer جديدة .. مثلا في هاذ المثال غادي يتصايبوا 3 ديال layers 7 |
8 | 9 | # This will create 3 layers 10 | RUN apt update 11 | RUN apt install ca-certificate 12 | RUN apt install curl 13 | 14 |
15 | و هاذشي لي ممكن يزيد الحجم ديال image ديالنا بزاف .. باش نعرفوا علاش خاصنا نفموا خاصية جديدة لي تايستعملها Storage Driver لي هي Copy On Write (COW) .. 16 | جميع الlayers في image ديالنا تايكونوا ثابتين Immutable و مايمكناش نبدلوا فيهم مباشرة Read Only ... 17 | باش نبدلو شي file كاين في شي layer في شي layer تحت منها .. Docker تايدير واحد النسخة لهذاك الfile في الlayer الجديدة و تايبدل فيها (مادام مايمكنش يبدل في Layer الفوقانية حيت هي Immutable) .. مثلا هنا في هاذ المثال، غادي يكوونوا عندنا 2 ديال النسخ ديال DevC.txt كل واحدة في Layer بوحدها .. 18 |
19 | 20 | # Create DevC.txt file in laye1 21 | RUN echo "DevC" > /DevC.txt 22 | # Copy DevC.txt from layer1 and add content to it 23 | RUN echo " Rabat" >> /DevC.txt 24 | 25 |
26 | أكثر من هاذشي، حتا المسيح Deletetions ماتايبدلوش في Layers لي قبل بل غير تايحجبوا هاذوك files لي مسحنا من Layer الحالية 27 | يعني ايلا رجعنا للمثال الأول جميع الfiles لي غادي تبدلهم apt غادي تدير منهم نسخ جديدة و هاذشي غادي يكبر حجم Image ديالنا بزاف. 28 | أخيرا الحل ديال هاذشي هي نديروا أقل عدد ممكن ديال Layers قدر المستطاع يعني المثال ديالنا ممكن نحولوه لشي حاجة بحال هاكا، لي غادي يصايب لينا غير layer واحدة 29 |
30 | 31 | # This will create 3 layers 32 | RUN apt update && apt install -y ca-certificate curl 33 | 34 |
35 | علاش هاذشي كاع؟ 36 | هاذ البلان ديال layers تايبان ماصالحش، ولك في الواقع هو مهم بزاف حيت تايعطينا الامكانية، نشاركوا layers بين بزاف ديال images و containers و تايعطينا القدرة على أننا نCache'ew هاذ الLayers بين Builds و نسرعوا Build . 37 |
38 | 39 |
40 | ملاحظات: 41 |
    42 |
  • كاينين Commands لي ماتايصايبوش layers جداد بحال Expose مثلا
  • 43 |
  • الStorage Drivers هوما واجهة لل Filesystems لي تايوفروا هاذوك الخاصيات بحال COW و Layering .. الFS الأكثر استعمالا هو OverlayFS 2
  • 44 |
45 |
46 | 47 | ![Layers](images/layers.jpg) 48 | -------------------------------------------------------------------------------- /day-18.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 18 2 | 3 |
4 | اليوم غادي نكملوا الهضرة على Dockerfiles و هاذ المرة غادي نهضروا على package managers و كيفاش نستعملوهم بطريقة مزيانة في Dockerfiles
5 | 6 | كيفما قلنا قبل في اليوم 17 docker تايخبي Images على شكل immutable layers و أننا مخاصناش نكثروا الlayers باش نتفاداو نزيدوا الحجم ديال Images ديالنا.
7 | 8 | حاجة آخرى هي خاصنا نحاولوا ما أمكن نحديوا Temporary Files بحال Build tools في layer في زدناهم، حيت كيفما قلنا قبل ايلا مشاو تابقاو ماغاديش يمكن نمسحوهم في شي Layer من بعد. 9 |
10 | 11 | RUN apt update && apt install -y git && git clone https://github.com/DevC_Rabat/DevC.git /DevC 12 | WORKDIR /DevC 13 | RUN chmod u+x install.sh && ./install.sh 14 | 15 |
16 | في المثال لي داز عندنا واحد المشكل .. ال Image ديالنا غادي يكون فيها git و الSource Code ديالنا لي حنا مامحتاجينهمش أصلا في Final Image و واخا نمسحوهم في Layer من بعد ماغاديش 17 | غير غادي يتخباو و غادي يبقى الحجم ديال Image كبير. 18 |
19 | 20 |
21 | بحال هاذ المشاكل تايتعاودوا بزاف مع Package Managers .. نشوفوا شي techniques باش نتفاداوهم في كل Package manager 22 | مشكل الupdate ديال الpackage list في layer بوحدها 23 | 24 | RUN apt-get update 25 | RUN apt-get install -y php 26 | 27 |
28 | 29 |
30 | بالاضافة لأنه غادي تزاد عندنا layer إضافية .. منين تانديرو apt-get update في layer بوحدها، الpackage list ماغاديش يبقى يتبدل بين Docker builds واخا نبدلوا packages .. حيت هاذشي الlayer ماغاديش تبدل و Docker غادي يبقى ديما يجبدها من الcache ديالو. 31 | تحديد الversions ديال packages
32 | 33 | من الأحسن دائما نديروا versions ديال packages لي تانآنسطاليو و نتفاداو Default version لي غادي ينقصوا من Visibility ديالنا و غادي يخليونا ماعارفينش شنو كاين في image ديالنا 34 | 35 | RUN apt-get update && apt-get install -y php7.3 git=2.1.3 36 | 37 |
38 | 39 |
40 | نستعملوا الversions اللخرين ديال Distributions 41 | النسخ القدام منين تاينديرو update لل package cache تايضطروا يتيليشارجيوا أكثر من الversion الجداد .. 42 | نتفاداو الpackages الزايدين 43 | في الimages المبنيين فوق من debian ممكن نقولو ل apt مايتيليشاجيش ال recommended packages 44 | 45 | RUN apt-get update && apt-get install -y --no-install-recommends php7.3 46 | 47 |
48 | 49 |
50 | نحيدوا package list و package cache في نفس الlayer 51 | باش نديروا هاذشي في debian 52 | 53 | RUN apt-get update && apt-get install -y --no-install-recommends php7.3 && rm -rf /var/lib/apt/lists/* && apt-get clean 54 | 55 | في أغلب الofficial base images ديال debian و ubuntu ال apt-get clean تاتدار أوتوكاتيطيا 56 | باش نديروا هاذشي في redhat-based distros 57 |
58 | 59 | RUN yum -y php && rm -rf /var/cache/yum 60 | 61 |
62 | في البوسط الجاي غادي نهضروا على كيفاش ننقصوا من size ديال image أكثر في Debian 63 |
-------------------------------------------------------------------------------- /day-19.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 19 2 | 3 |
4 | في البوسط لي قبل هضرنا على كيفاش ننقصوا الحجم ديال Docker image و في هاذ البوسط غاذي نديرو واحد case study على Debian based images 5 | 6 | أول حاجة هي package cache w package lists:
7 | منين تانديروا apt-get update تاتعمر تايجبد lists ديال الpackages كاملين لي كاينين في repositories لي كاينة في `/etc/apt/sources.list` و تايتيليشارجيهم ل `/var/lib/apt/lists/` و في نفس الوقت منين تانديروا `apt-get install` الpackages لي تايتيليشارجاو تايخبيهم apt في `/var/cache/apt/archives/` في حالة ما حتاجيناهم من بعد. 8 | أول حاجة غانديروها هي غادي نتخلصو من هاذشي كامل من بعد مانساليو installation 9 | 10 | RUN apt-get update && \ 11 | apt-get install -y --no-install-recommends \ 12 | autoconf gcc g++ make git && \ 13 | git clone $REPO /app && \ 14 | cd /app && \ 15 | make && make install && \ 16 | rm -rf /var/lib/apt/lists/* 17 | # apt-get clean will be executed automatically if the image is official 18 | 19 | باستعمال هاذشي جميع الfiles الزايدين لي غادي يزيدهم apt غادي يتمسحوا في نفس الlayer و هاكا غادي نقتاصدو بزاف ديال space في image ديالنا ..ال build Dependencies 20 | 21 | في المثال لي داز آ جميع الpackage لي آنسطالينا ماغاديش نستعملوهم في production و آنسطاليناهم غير باش نBuild'ew آبليكاسيون ديالنا .. 22 | 23 | يعني غادي يخاصنا نحيدوهم في الأخير .. أبسط طريقة هي نكوبييو هاذيم الليست كاملة و نديروها قدام واحد apt-get remove و لكن ايلا كانوا كتار و مفرقين على مراحل غادي تصعاب علينا 24 | القضية .. 25 | 26 | الحل هو نستعملوا apt-mark لي تاتبدل لينا الاعدادات ديال ال packages اللي تانعطيوها .. لي تايهمنا من هاذ ااعدادات هوما manual و auto لي تايحددوا واش الpackage تآنسطالا manually أو أنه تآنسطالا automatically as some other package dependency . 27 | 28 | و من بعد غادي نستعملوا `apt-get purge -y --auto-remove` لي تاتمسح جميع الpackages لي تآنسطالاو auto و مابقيناش محتاجيهم .. و النتيجة غادي تولي شي حاجة بحال هاكا. 29 | 30 | RUN apt-get update && \ 31 | # Before the installation, Save the list of all manual packages to a variable 32 | savedAptMark="$(apt-mark showmanual)"&& \ 33 | # Install 34 | apt-get install -y --no-install-recommends \ 35 | autoconf gcc g++ make git && \ 36 | git clone $REPO /app && \ 37 | cd /app && \ 38 | make && make install && \ 39 | rm -rf /var/lib/apt/lists/* && \ 40 | # mark all the packages as auto 41 | apt-mark auto '.*' > /dev/null && \ 42 | # get the list of previously installed packages and mark them as manual 43 | [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark && \ 44 | # Delete all the packages that are marked auto 45 | apt-get purge -y --auto-remove 46 | # apt-get clean will be executed automatically if the image is official 47 | 48 | هنا قبل مانبداو لانسكالاسيون ديال build dependencies تانقيدوا لا ليست ديال packages لي أصلا كاينين .. من بعد تانآنسطاليو داكشي ديالنا و تانخدموا بيه و تاينماركيوه auto باش تمسحوا autoremove 49 | 50 | ملاحظات: 51 | 52 | - في المثال لي الفوق مادرتش واحد المرحلة مهمة لي هي نماركي dependencies ديال جميع binaries لي عندنا في image باش يبقاو خدامين 53 | 54 | ``` 55 | find /usr/local -type f -executable -exec ldd '{}' ';' \ 56 | | awk '/=>/ { print $(NF-1) }' \ 57 | | sort -u \ 58 | | xargs -r dpkg-query --search \ 59 | | cut -d: -f1 \ 60 | | sort -u \ 61 | | xargs -r apt-mark manual 62 | ``` 63 | 64 | السطر 1 تانقليو على binaries ديالنا و تانجبدو dependencies ديالهم ب ldd و في السطر 2 و 3 تانجبدو السميات ديالهم .so وتانرتبوهم و في السطر 4 و 5 و 6 تانقلبوا على السميات ديال package names و تانرتبوهم .. و في السطر الأخير تانماركيوهم manual 65 | 66 | > ايلا بغيتي تتعمق أكثر ضرب طليلة على الريبو ديال docker official images في github 67 | https://github.com/.../blob/master/7.4/buster/fpm/Dockerfile 68 | 69 |
70 | -------------------------------------------------------------------------------- /day-20.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 20 2 | 3 |
4 | في البوسط لي قبل هضرنا على كيفاش ننقصوا الحجم ديال Docker image في Debian based images و في هاذ البوسط غادي نديرو case study آخرى على Alpine based images 5 | ا Alpine linux هي واحد الdistribution صغيرة بزاااف مقارنة مع لاخرين و لي مديورة خصيصا للاستعمال في container images . 6 | 7 | القضية هنا أسهل مادام package manager فيه features لي غادي ينفعونا ننقصوا من الحجم ديال الimage ديالنا من اللخر .. 8 | 9 | ### ال package cache w package lists 10 | 11 | الpackage manager ديال alpine سميتو apk .. فيه واحد الoption --no-cache لي تاتعطيني الامكانية نمسحوا الcache كامل من بعد الأنسطالاسيون. 12 | 13 | RUN apk add --no-cache autoconf gcc g++ make git 14 | 15 | ### ال build Dependencies 16 | 17 | هاذ المرة عاوتاني القضية أسهل، باستعمال --virtual لي تاتعطينا الامكانية باش نصايبو named groups ديال الpackages لي ممكن نمسحو بيه من بعد جميع الpackages ب apk del 18 | 19 | RUN apk add --no-cache --virtual .build-deps autoconf gcc g++ make git && \ 20 | git clone $REPO /app && \ 21 | cd /app && \ 22 | make && make install && \ 23 | apk del .build-deps 24 | 25 |
26 | -------------------------------------------------------------------------------- /day-21.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 21 2 | 3 |
4 | من بعد ماهضرنا على good practices ديال package management في dockerfiles دابا نهضروا على شي نضائح حول الستيل ديال dockerfile 5 | أول حاجة و لي كانت حتى في البوسطات لي دازو هي نقسموا RUN Commands الطوال لعدة سطور مفرقين ب \&& أو \; 6 | 7 | RUN apk add --no-cache --virtual .build-deps autoconf gcc g++ make git && \ 8 | git clone $REPO /app && \ 9 | cd /app && \ 10 | make && make install && \apk del .build-deps 11 | 12 | أبعد من هاذشي ممكن في حالة package installation من الأحسن نديرو كل واحد في سطرو نرتبوهم Alphabetically 13 | 14 | RUN apk add --no-cache --virtual .build-deps \ 15 | autoconf \ 16 | g++ \ 17 | gcc \ 18 | git \ 19 | make 20 | 21 | و أخيرا ايلا بغينا نزيدو شي سطر في الأول أو في الأخير ديال هاذ RUN غادي يخاصنا ضروري نبدلوه يعني و هاذشي غادي يخلق لينا مشكل ايلا كنا خدامين ب Git مداام أن git diff ديالنا غادي تطلع فيها أن السطر الأول تبدل واخا حنا زدنا فيه \ && في اﻷخير. 22 | 23 | RUN set -eux && \ # diff here 24 | apk add --no-cache --virtual .build-deps \ # and here 25 | autoconf \ 26 | g++ \ 27 | gcc \ 28 | git \ 29 | make && \ # diff here 30 | git clone $REPO # and here 31 | 32 | الحل نأونكادريو هاذيك الRUN بcommands ماتايديرو والو بحال : .. لي ماتاتدير والو من غير أنها تاتexpand الparameters لي تانعطيوها. 33 | 34 | RUN : && \ 35 | apk add --no-cache --virtual .build-deps \ 36 | autoconf \ 37 | g++ \ 38 | gcc \ 39 | git \ 40 | make && \ 41 | : 42 | 43 | دابا ايلا زدنا شي سطر الdiff غادي يكون فيها غير السطر لي زدنا 44 | 45 | RUN : && \ 46 | set -eux && \ # diff only here 47 | apk add --no-cache --virtual .build-deps \ 48 | autoconf \ 49 | g++ \ 50 | gcc \ 51 | git \ 52 | make && \ 53 | git clone $REPO # diff only here 54 | : 55 | 56 |
-------------------------------------------------------------------------------- /day-22.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 22 2 | 3 |
4 | هاذ البوسط غادي نهضروا على واحد من أهم المواضيع لي كنت بغيت نهضر عليهم، مادام فيهم بزاف ديال الغموض و لليهوما ttys و standard I/O streams 5 | هاذ المفهومين غادي ينفعونا نفهموا شي جزئيات في Docker run و Docker create و عموما مهمين بزاف و غادي نلقاوهم في كل بلاصة في عالم Containers و Linux . 6 | 7 | ### الTTY 8 | 9 | من أهم المبادئ لي في لينكس هي Everything is a file يعني جميع الحوايج لي كاينين في السيتام ديالنا تايتعامل معها الkernel على أساس أنها files 10 | من أهم الأمثلة الDevices .. جميع الDevices لي عندنا مجموعين في files في واحد الضوسيي سميتو dev/ و أغلبيتهم ممكن نقراو منهم و نكتبوا فيهم (حيت هوما مجرد files).. مثلا ممكن تحل الكاميرا ديال البيسي ديالك و تشوف راسك باستعمال media player ديال مثلا vlc أو mpv 11 | 12 | mpv /dev/video0 13 | 14 | هاذ الDevices منهم لي تايكونوا حقيقين و مبرونشين في الحاسوب ديالنا بحال disk في `dev/sdX/` (السمية تاتختالف على حساب الديسترو، و على حساب الconnectors ... و الكاميرا `dev/video0/` (تاهي تاتختالف على حساب السيستام ديالك) 15 | 16 | و منهم لي تايكون مصايبهم kernel باش يديرو شي خدمة بحال `dev/null/` و `dev/random/` 17 | 18 | من أهم الdevices لي تانلقاو هوما `dev/ttyx/` (مع x عدد صحيح طبيعي) .. لي تايشيرو لTeleType .. 19 | هاذ الTeleTypes هوما واحد الآلات كانوا تايتسخدموا شحال هاذي باش يدخلو input و يخرجوا output من الحواسيب (بحال لي في التصورية) 20 | 21 | مع الوقت TeleTypes مابقاوش ولكن بقات هاذوك Drivers لي مكلفين بيهم في Unix و من بعدو Linux و ولا عندهم استعمال آخر (نفس الاستعمال غير الDevices لي تبدلو) 22 | 23 | اليوم tty هوما واحد Devices لي تايصايبهم Kernel و لي تاياخدوا input ديالنا من Keyboard و تايوريونا output في Screen .. هوما لي تانسميوهم اليوم الTerminal 😁😁 24 | الLinux Kernel تايصايب بزاف ديل tty (على حساب السيستام ديالك) و ممكن نتنقلوا بينات شي وحدين منهم باستعمال CTRL+ALT+F1-9 25 | 26 | كاين مشكل .. 27 | كيفما قلنا kernel تايصايب لينا واحد العدد محدود من terminals و لكن في الوقت ديالنا مع Desktop environment ممكن نحلو مئات الterminals مغلا في tmux و ماكاينش مشكل .. ماشي غادي يساليو لينا ttys ؟ 28 | الحل هنا هو الuserpace ttys أو pseudo tty أو ptty .. هاذ النوع الجديد ديال الttys ماتايكونش مبرونشي نيشان مع kernel و تايعطينا الامكاينية نصايبو بزاف ديال ttys .. مادام تايخدم ب Master Slave Architecture لي تاتكون فيها مكون master واحد ptmx و بزاف ديال المكونات slave لي هو pts و لي هوما لي تايهمونا 29 | التطبيقي 30 | باش نعرفوا اينا tty حنا فيه يكفي نستعملو الكوموند 31 | 32 | tty 33 | # output /dev/pts/14 34 | 35 | و باش نبدلو الإعدادات ديال شي tty تانستعملوا stty مثلا ايلا درتي full screen و داكشي بقى مقطع ممكن تستعمل stty باش تبدل الطول و العرض ديال tty 36 | 37 | stty -F /dev/pts/10 rows 29 columns 10 38 | stty -a # to display all settings 39 | 40 | إيلا بغيتي تعرف أكثر على ttys ممكن تشوف هنا 41 | 42 | http://www.linusakesson.net/programming/tty/index.php 43 | 44 | ### ال standard I/O streams 45 | 46 | الموضوع الثاني هو stdio streams .. في لينكس كل process تاتكون عندوا واحد file descriptor table لي تايكون فيها جميع files لي حالهم و كيفاش تايتعملهم مرتبين من 0 لواحد الرقم محدد غالبا تايكون 1024 و ممكن نبدلوه. 47 | من هاذ الfile descriptors تايكون عندنا واحد 3 مميزين ليهموما من 0 ل 2 أو بالترتيب STDIN و STDOUT و STDERR .. 48 | 49 | هاذو بكل بساطة تايتكلفوا ب standard I/O يعني أي حاجة تاتدخل و تاتخرج بالشكل default/standard يعني باستعمال print و scanf (تقريبا، حيت حتى هاذو ممكن نقولو ليهم يكتبوا في بلايص آخرين ماشي standard) 50 | 51 | المهم باش نشوفوا هاذ الfd ممكن نمشيو ل proc/ .. ايلا كان pid ديال الprocess ديالنا هو 1200 نلقاوهم في 52 | 53 | ls /proc/1200/fd 54 | 55 | للاشارة هاذو تاهوما files وممكن نقراو منهم و نكتبو فيهم ب unix utils مثلا هاذي 56 | 57 | echo "Hello DevC Rabat" > /dev/1200/fd/0 58 | 59 | مكافئة لأننا ندخلو input لبورغرام ديالنا نيشان من terminal (جربوها مع شي scanf في شي بروغرام.) 60 | 61 | ### ال standard I/O streams و علاقتهم بTTYs 62 | 63 | أغلب الprocesses ليتاrun'ew في terminals تايكونوا std I/O streams ديالهم كاملين مبرونشيين مع tty device لي هوما خدامين فيه .. 64 | مثلا ايلا شدينا واحد البروغرام DevC.bin و خدمناه في `dev/pts16/` عموما (ايلا مابدلناش في اللوجيك لداخل أو ايلا مادرناش redirections أو pipes في command line) غادي يكونوا الfds من 0 ل2 مجرد symlinks ل `dev/pts16/` 65 | 66 | ./DevC.bin # run in the foreground 67 | # from another tty 68 | ls -l /proc/1234/fd 69 | total 0 70 | lrwx------ 1 devc devc 64 Sep 12 02:38 0 -> /dev/pts/16 71 | lrwx------ 1 devc devc 64 Sep 12 02:38 1 -> /dev/pts/16 72 | lrwx------ 1 devc devc 64 Sep 12 02:38 2 -> /dev/pts/16 73 | 74 | باش نعرفوا واش شي fd مبرونشي مع شي tty ممكن نقلبو في proc/ مباشرة ولا ممكن نستعملوا واحد الfunction سميتها `(fd)isatty` من وسط الprogram ديالنا .. 75 | 76 | ملاحظات 77 | 78 |
    79 |
  • أغلب اللعيبات لي في docker مبنيين على Linux technologies ذاكشي علاش غادي يخاصنا نفهمو شوية Linux ايلا بغينا نفهموا Docker و Containers عموما
  • 80 |
81 | 82 |
83 | 84 | ![Terminal](images/terminal.jpg) 85 | -------------------------------------------------------------------------------- /day-23.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 23 2 | 3 |
4 | اليوم غادي نهضروا على شوية ديال المفاهيم Terminology لي عندها علاقة ب container images .. هاذ المفاهيم غادي ينفعونا في البوسطات الجايين. 5 | المفاهيم هي: 6 | 7 | ### الContainer Image : 8 | 9 | هي واحد المجموعة ديال الملفات غالبا tar files لي مرتبين على شكل طبقات layers. كل طبقة تاتخزن التغيير في Filesystem لي تدار مقارنة بالطبقة لي قبل منها. هاذ التغييرات تايتدارو في أغلبية دالحالات بفعل الكومندس لي في Dockerfile ديالنا و تايتسماو بلغة containers ب Image Filesystem Changeset أو Image Diff 10 | مثلا ايلا عندنا في الDockerfile 11 | 12 | ``` 13 | RUN touch DevC.md 14 | ``` 15 | 16 | المحتوى ديال Changeset غادي يكون هاذاك DevC.md لي زدنا. 17 | 18 | ### ال Container registry 19 | 20 | هي واحد البلاصة في ممكن نخزنوا الimages ديالنا بطريقة فعالة و optimized .. من registry المعروفين هوما Docker hub و Quay و Gitlab registry و gcr و ecr و غيرهم 21 | 22 | ### ال image repository و image tag 23 | 24 | منين تانبغيو نbuildiw شي image تايخاصنا نحددو 2 ديال الأجزاء من بعد ديك t- الجزء الأول ديال الrepository و الثاني الtag .. 25 | الrepository ممكن يكونوا فيه بزاف ديال images بtags مختلفين. مثلا 26 | 27 | ``` 28 | php:fpm-buster 29 | php:apache 30 | php:7.3-alpine 31 | ``` 32 | 33 | الrepository هو php و الجزء لي من بعد تايتسمى tag و تايحدد image مختلفة. منين غادي نpush'ewهم كاملين في شي container registry غادي يكونوا تاينتاميو لنفس repository 34 | 35 |
36 | 37 | ![Container Lifecyle](lifecycle.jpg) 38 | -------------------------------------------------------------------------------- /day-24.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 24 2 | 3 |
4 | كيفاش Docker تايخزن container images ؟ 5 | باش نجاوبوا على السؤال غادي يخاسنا نختاروا شي container image ونجبدوها لعندنا. 6 | 7 | docker save node:alpine > node.tar 8 | skopeo docker://node:alpine docker-archive://node.tar 9 | 10 | هاذشي غادي يعطينا واحد الفيشي tar لي فيه الimage ديالنا، هاذ الفيشي ممكن نديرو بيه لي بغينا بحال مثلا نسيفطوه في email لشي حد و ديك الساعة هة يimporteha عندو 11 | دابا آجي نشوفو شنو فيه لداخل 12 | 13 | tar xvf node.tar 14 | 15 | - ال`manifest.json` و هو لي فيه معلومات عامة على image بحال فين كاينة config ديال الimage و الtags لي لاسقين مع image و سميات ديال layers لي كاينين و الترتيب ديالهم 16 | - الrepositories فيه معلومات على repository ديالنا و tags لي معاها 17 | - الconfig file تايكون جميع الconfigs ديال image بحال exposed ports و architecture و Workdir و user و CMD و بزاف ديال الحاجات آخرين لي تانزيدوهم في Dockerfile 18 | - الlayers: كل واحدة تاتكون في folder ديالها الخاص لي تايكون السمية ديالو هو الID ديال الlayer و لداخل فيه تيكون فيشيي سميتو json فيه المعلومات و الconfig الخاصة بديك layer و فيشي سميتو VERSION اللي فيه json schema version ديال هاذاك الفيشي json 19 | 20 | الdocker image specification V1 21 | هاذشي لي هذرنا عليه تايتسمى Docker image spec v1 و لي تايحدد كيفاش docker كان تايخزن container images في الأول .. دابا Docker داز ل Docker imager spec v2 22 | من الحوايج لي فيهم مشكل في هاذ النسخة الأولى ديال specification هوما 23 | 24 | - ماكاينينش قيود على كيفاش layer id خاص يكون it is an implementation detail، و عموما تايكون عدد عشوائي من 256bits و هاذشي كافي باش كل layer تكون عندها id ديالها مختلف على الآخرين .. و لكن ايلا تبدلات شي حاجة فيها ماعندناش شي طريقة باش نعرفوا بلي تبدلات و الimages لي تايعتامدوا عليها يقدر تطرا فيهم مشاكل regressions 25 | - هاذ البلان تايتسمى content-addressablity 26 | - كل layer عندها config file ديالها لي فيه شي حوايج بحال env و cmd و غيرهم، و لكن هاذشي ماعندو تا معنى مادام حنا ماكانستعملوش layers بوحدهم و لكن تانخدمو images 27 | - منين بدا docker كان تايدعم x86_64 architectures و لكن مع الوقت تطورات الأمور و ولينا محتاجين الدعن ديال architectures آخرين و هاذشي ماكاين حتى شي طريقة باش نعبرو عليه باستعمال Docker image spec V1 28 | 29 | هاذشي كامل خلا Docker تدوز لDocker image spec V2 لي تاتحل هاذ المشاكل .. و تاتزيد حوايج آخرين مهمين 30 | 31 | ال Docker image specification V2 فيها 2 نسخ: 32 | 33 | - النسخة الأولى V2 Schema1 و لي تاتقدم واحد الطبقة ديال backward compatibility مع V1 34 | - النسخة الثانية V2 Schema2 لي يحال V2S1 و لكن ماشي compatible مع V1 و أكثر تعبيرا .. هاذ القدرة التعبيرية تاتجي من Json Mediatypes الجداد لي تزادو و كيفاش تفرقات الأمور و ولات modular أكثر و من جهة أخرى ولات أغنى 35 | 36 | أهم الحاجات اللي تبدلوا في V2S2 هوما 37 | - الlayers ولاو files لي فيهم changeset فقط و مابقاش فيهم config خاصة و تاتولي عندنا config عامة ديال image فقط. 38 | - الmanifest.json ولا أكبر fat و أكثر تعبيرا .. عموما ولا فيه واحد list ديال manifests و كل واحد فيهم خاص بarchitecture معينة. 39 | - كل manifest ولات فيه size و platform لي تاتجمع معلومات على architecture و os و غيرهم و digest لي تايكون فين hash value ديال config file. 40 | و أخير الmanifest القديم ديال V1 تعوض بImage manifest و لي فيه معلومات على image و layers لي فيها و كل واحدة type ديالها، و size و digest ديال tar file لي تايطينا content addressablity لي دوينا عليها قبل. 41 | 42 | على أساس هاذ الفورما V2S2 جات منظمة Open Container Initiative و دارت واحد Specification ديالها و لي تقريبا compatible مع V2S2 (مختلفين غير الأسماء و Image layout) .. و دابا ولا عندنا standard لي ممكن نتبعوه باش نصايبوا images ديالنا و يكونوا compatible مع أي OCI Compliant Container Engine. 43 | 44 | - الصورة الأولى فيها الفرق بين oci image layout و docker v2s2 45 | - الصورة الثانية فيها الفرق بين الmanifests لي كيفما تايبان لينا compatible مع بعضهم و الفرق غير في السميات ديال Mediatypes 😃 46 | 47 |
48 | 49 | ![OCI image 1](images/oci-image-1.jpg) 50 | ![OCI image 2](images/oci-image-2.jpg) 51 | -------------------------------------------------------------------------------- /day-25.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 25 2 | 3 |
4 | 5 | اليوم غادي نهضروا على واحد البلان زوين بزاف و مفيد، و لي غادي يقدر ينفع بزاف ديال الناس، خاصة الناس لي خدامين Docker في CI/CD 6 | في Docker عندنا بزاف ديال المكونات منهم Docker Daemon لي هو لي تانهضروا معاه بDocker CLI أو Docker-compose باش يقضي لينا الغرض. 7 | 8 | التواصل مع هاذ الDocker Daemon تايتدار إما عن طريق Unix Socket لي هو فيشيي تانطتبوا فيه باش نهضروا مع Docker أو عن طريق TCP لي هو port تانهضروا فيه مع Docker 9 | واخا ال Unix Socket هو default في Docker تايبقى Limited حيت مايمكنش نهضروا مع Docker daemon إلا ايلا كان في نفس الحاسوب. ذاكشي علاش TCP بلان زوين. 10 | 11 | ```bash 12 | #### Dockerd #### 13 | # start docker daemon (listen to Unix socket) 14 | sudo dockerd -H unix:///var/run/devc.sock 15 | 16 | # start docker daemon (listen to default port on 2 interfaces) 17 | sudo dockerd -H tcp://192.168.59.106 -H tcp://10.10.10.2 18 | 19 | # start docker daemon (listen to 9999 tcp port on all tnterfaces) 20 | sudo dockerd -H tcp://0.0.0.0:9999 21 | 22 | 23 | 24 | ### Docker CLI #### 25 | # List all running containers on first docker host (daemon) 26 | sudo docker -H unix:///var/run/devc.sock ps 27 | 28 | # Run DevC container on the second docker host (equivalent) 29 | sudo docker -H tcp://192.168.59.106 run -it devc:latest sudo docker -H tcp://10.10.10.2 run -it devc:latest 30 | ``` 31 | 32 | و لكن TCP تايجي بمشاكلوا تا هو حيت غادي يخلي Docker daemon ديالنا محلول للناس لي معانا في الريزو، و غادي يخاصنا نأمنوه و نسيكيريزيوه باش مانتصيدوش. 33 | 34 | كاين واحد الحل وسط: Docker تايعطينا الإمكانية أننا نتكونيكطاو لDocker daemon عن بعد باستعمال SSH و ندوزو الكوموند ديالنا عبر SSH النيت بلا مانحتاجوا نExposew الDaemon 35 | . 36 | 37 | ```bash 38 | #### Docker using SSH #### 39 | # List running containers on the devc docker host via SSH 40 | # This requires SSH access only (docker daemon is not exposed to the outside world) 41 | sudo docker -H ssh://devc-user@devc.com ps 42 | 43 | # We can use DOCKER_HOST env variable to specify the docker host 44 | # When specifying DOCKER_HOST we can ommit the -H directive 45 | export DOCKER_HOST=ssh://devc-user@devc.local 46 | # These commands will be run on the remote machine devc.local 47 | sudo docker run -d devc:latest 48 | sudo docker-compose -f devc-stack.yml up 49 | ``` 50 | 51 |
52 | -------------------------------------------------------------------------------- /day-26.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 26 2 | 3 |
4 | 5 | المرة لي فاتت هضرنا على docker daemon و كيفاش ممكن نستعملوا docker cli باش نهضروا معاه فينما كان باستعمال TCP أو باستعمال Unix Sockets مع SSH أو بلا SSH 6 | 7 | دابا آجي نتخيلوا عندنا بزاف ديال Docker daemons في بزاف دالبلايص، مثلا واحد في الحاسوب ديالنا، وواحد في الريزو ديال الخدمة مExposer في ماشين سميتها devc.local في البورت 10000 و واحد في أنترنت devc.com و لي ممكن نهضروا معاه غير بSSH 8 | 9 | كيفاش ممكن نهضروا مع هاذشي كامل بسهولة ؟ 10 | هنا فين تايجي الدور ديال Docker contexts .. ممكن تصايبوا context لكل واحد من هاذز لي هدرنا عليهم و نبقاو نسويتشيو بيناتهم بسهولة. 11 | 12 | ```bash 13 | # Create docker contexts 14 | docker context create --docker host=unix:///var/run/docker.sock mine 15 | docker context create --docker host=tcp://devc.local:10000 devc-local 16 | docker context create --docker host=ssh://devcuser@devc.com devc-com 17 | 18 | # List all contexts 19 | docker context list 20 | 21 | # Switch to our local one 22 | docker context use mine 23 | ## Execute commands against my docker daemon 24 | docker ps 25 | docker run devc:latest 26 | 27 | # Switch to DevC local context 28 | docker context use devc-local 29 | ## Execute commands in DevC local daemon via TCP 30 | docker ps 31 | docker run devc:latest 32 | 33 | # Switch to devc-com context 34 | docker context use devc-com 35 | ## Execute commands in the devc-com host via ssh. 36 | docker ps docker 37 | run devc:latest 38 | ``` 39 | 40 |
41 | -------------------------------------------------------------------------------- /day-27.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 27 2 | 3 |
4 | 5 | من الحوايج لي ممكن نستعملوا docker فيهم هو تخدموا stacks ديالنا، (يعني أبليكاسيون بكلشي ليها) و هاذشي ممكن نديروه بسهولة باستعمال docker compose . 6 | 7 | من الحوايج لي صعيب نديرهم بdocker compose هو batch computing يعني بزاف ديال الحوايج لي غادي نرانيوهم بواحد الترتيب و ربما غادي يكونوا مرتبطين ببعضهم. 8 | في الحالات الصعابين ممكن نستعملوا شي tool معين بحال Kubernetes و لكن في أغلب الحالات، سكريبت كافي. 9 | 10 | من الحوايج لي ممكن ينفعونا في هاذ القضية بزاف هي docker wait لي كاتتسنى واحد الcontainer حتى تايسالي و تاتكتب exit status ديالو 11 | مثال في الكود ممكن تستعمل هاذ البلان باش تدير CI/CD ديالك راسك 🤪 12 | 13 |
14 | 15 | ```bash 16 | # Download music from internet 17 | jobl=$(docker run -d --rm -v /home/devc/Music:/Music devc-music-downloader:latest) 18 | exit_code=$(docker wait $jobl) 19 | test $exit_code -eq 11 || exit $exit_code 20 | 21 | # convert it using ffmpeg 22 | job2=$(docker run -d --rm -v /home/devc/Music:/Music -v ./transcode.sh:/transcode sh linuxserver/ffmpeg ) 23 | exit_code=$(docker wait $job2) 24 | test $exit_code -eq 11 || exit $exit_code 25 | 26 | # Upload it to s3 bucket 27 | job3=$(docker run -d --rm -v /home/devc/Music:/Music devc-s3-uploader:latest) 28 | exit_code=$(docker wait $job3) 29 | test $exit_code -eq 11 || exit $exit_code 30 | 31 | # Notify Music Server to sync new music from S3 32 | job4=$(docker run -d --rm devc-mediaserver-notifier:latest) 33 | exit_code=$(docker wait $job4) 34 | test $exit_code -eq 11 || exit $exit_code 35 | 36 | ``` -------------------------------------------------------------------------------- /day-28.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 28 2 | 3 |
4 | 5 | في لينكس كاينين 2 أنواع ديال الprocesses، الpriviliged processes و الunpriviliged processes. 6 | 7 | الpriviliged processes تايكونوا يقدروا يدروا لي بغاو و العكس بالنسية للpriviliged processes، 8 | يعني ايلا كتبنا شي بروغرام تايدير شي حوايج لي غير root لي تايقددر يديرهم ماغاديش يقدر يديهم ايلا خدمناه بUnpriviliged user 9 | 10 | هاذشي كان قبل النسخة 2.2 ديال لينكس .. من بعد ولاو الRoot priviliges مفرقين ماشي مجموعين، و هاذشي لي سميتو Capabilities. 11 | 12 | أي Process ولا ممكن نعطيوه واحد العدد معين ديال Capabilities بلا مانعطيوه الPriviliges كاملين. 13 | كاينين بزاف ديال Linux Capabilities منهم CAP_KILL لي كاتخلي Process يقدر يسيفط Signals ل processes آخرين. و CAP_SETUID و CAP_SETGID لي تايخلي الprocess يبدل المعلومات الخاصة ب user و group ديالو. 14 | 15 | آDocker تايخدم بزاف بLinux Capabilities باش يزير Containers 😆😆 و مايخليهمش يديروا لي بغاو. 16 | في Docker عندنا By default كل container تايجي بواحد الLinux capabilities و ممكن نزيدوا ليه شي واحدين و ننقصوا لي آخرين باستعمال cap-add و cap-drop 17 | 18 |
19 | 20 | ```bash 21 | • • • 22 | # Prevent container from setting capabilities of processes and from writing to the kernel audit logs 23 | docker run --cap-drop=setfcap --cap-drop=audit_write devC:latest 24 | 25 | # Drop all capabilities besides setuid and setgid 26 | docker run --cap-drop=all --cap-add=setuid --cap-add=setgid devC:latest 27 | 28 | # Prevent container from binding to privileged ports (< 1024 inside its namespace) 29 | docker run --cap-drop=net_bind_service devC:latest 30 | 31 | # Give the container SYS_ADMIN capabilities (equivalent to root) 32 | docker run --cap-add=CAP_SYS_ADMIN devC:latest 33 | ``` -------------------------------------------------------------------------------- /day-29.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 11 2 | 3 |
4 | اليوم غادي نهضروا على CMD و ENTRYPOINT .. هاذ الموضوع فلسفي و أزلي في Docker و متلف العالم كامل و منهم أنا ..
5 | عموما منين تانbuild'ew شي container image تانكونوا أمام 2 ديال الخيارات .. 6 |
7 | 8 |
    9 |
  • الاول هو أن الimage تاتكون عبارة عن package للآبليكاسيون ديالنا .. يعني تانوجدو كّاع ذاكشي لي خاص الآبليكاسيون باش تخدم في runtime و تانقولو لDocker أنها Runnable و كيفاش غادي يrunيها.
    10 | هنا تانستعملوا Docker من اجل Packaging يعني في آخر المطاف هاذيك Image غادي هي الطريقة الكافية باش أي واحد يخدم الأبليكاسيون ديالنا (Process)
    11 | في هاذ الحالة كايخاصنا نقولو لDocker منين يجي image ديالنا، يعني شناهو الProcess لي تايشكل الهوية ديال أبليكاسيون ديالنا. و هذا هو entrypoint ديال image ديالنا.
    12 | هاذا هو الusecase الأكثر شيوعا ديال docker و images في هاذ السياق هوما images ديال أبليكاسيونات ديالنا لي تانصايبو. 13 |
  • 14 |
15 | 16 |
    17 |
  • الخيار الثاني هو تانستعملو docker باش نصايبو واحد الوسط مناسب (يعني فيه libs و dependencies لي بغينا) فين نrun'ew شي commands و شي Applications ديالنا.
    18 | هنا كانهضرو على images بحال ديال gnu/linux distro ولا ديال programming ecosystems بحال python أو node.js ....
    19 | في هاذ الحالة image ديالنا ماتاتكونش مراد منها تكون package و لكن تاتكون ecosystem .. و هاذشي لي تايخليها ماتايكونش عندها Entrypoint واحد مفروض على user في runtime .. و لكن بالعكس تايكون مطلوب منها تكون قادرة تexecute واحد العدد ديال commands aka CMD
    20 | في هاذ الUsecase تايكون ممكن لينا نحددوا CMD في الBuild و لكن ماتاتكونش مفروضة علينا في الRun و تايمكن لينا نبدلوها بسهولة
    21 | دابا من بعد ما هضرنا على ENTRYPOINT و CMD و الفرق بيناتهم و Motivation ديال كل واحدة .. آجي نشوفو كيفاش نخدموهم.
    22 | عمليا، ENTRYPOINT و CMD عندهم نفس المفعول في أغلب الحالات.. الفرق هو أن CMD ممكن تبدلوها بcommand لي بغينا في Runtime 23 |
  • 24 |
25 | 26 | # dockerfile 27 | ... 28 | ENTRYPOINT ["node", "devc.rabat.js"] 29 | ... 30 | # --- 31 | 32 | # this will run the devc rabat node application. 33 | docker run -it devc:rabat 34 | 35 |
36 | نفس المثال بCMD 37 |
38 | 39 | # dockerfile 40 | ... 41 | CMD ["node", "devc.rabat.js"] 42 | ... 43 | # --- 44 | 45 | # this will run the devc rabat node application. 46 | docker run -it devc:rabat 47 | # but this will run the devc casa node application. 48 | docker run -it node devc.casa.js 49 | 50 |
51 | واحد من usecases الزوينين لCMD هو نستعملوها باش ندوزو Parameters لENTRYPOINT ديالنا مادام المحتوى ديال CMD دائما تايتزاد في الأخير (هاذ اللعيبة تاتخدم في Exec form فقط) 52 |
53 | 54 | # dockerfile 55 | ... 56 | CMD ["--help"] 57 | ENTRYPOINT ["node", "devc.js"] 58 | ... 59 | # --- 60 | 61 | # this will display the help message for our app 62 | docker run -it devc:rabat 63 | # this will run our app with awesome argument. 64 | docker run -it devc:rabat awesome 65 | 66 | --- 67 |
ملاحظات: 68 |
    69 |
  • حتى ENTRYPOINT ممكن نبدلوه في Runtime باستعمال entrypoint-- و لكن غير منصوح بيها حيث غانكون تانبدلو الهوية ديال container بحد ذاتها
  • 70 |
  • كنت بغيت نهضر على One process per container Philosophy و كيفاش تاتأثر في Design ديال Dockerfiles و CMD و ENTRYPOINT و لكن تايبان لي غادي نخليوها لمرة أخرى
  • 71 |
72 |
-------------------------------------------------------------------------------- /day-30.md: -------------------------------------------------------------------------------- 1 | # 30 Days of Docker - Day 11 2 | 3 |
4 | اليوم غادي نهضروا على CMD و ENTRYPOINT .. هاذ الموضوع فلسفي و أزلي في Docker و متلف العالم كامل و منهم أنا ..
5 | عموما منين تانbuild'ew شي container image تانكونوا أمام 2 ديال الخيارات .. 6 |
7 | 8 |
    9 |
  • الاول هو أن الimage تاتكون عبارة عن package للآبليكاسيون ديالنا .. يعني تانوجدو كّاع ذاكشي لي خاص الآبليكاسيون باش تخدم في runtime و تانقولو لDocker أنها Runnable و كيفاش غادي يrunيها.
    10 | هنا تانستعملوا Docker من اجل Packaging يعني في آخر المطاف هاذيك Image غادي هي الطريقة الكافية باش أي واحد يخدم الأبليكاسيون ديالنا (Process)
    11 | في هاذ الحالة كايخاصنا نقولو لDocker منين يجي image ديالنا، يعني شناهو الProcess لي تايشكل الهوية ديال أبليكاسيون ديالنا. و هذا هو entrypoint ديال image ديالنا.
    12 | هاذا هو الusecase الأكثر شيوعا ديال docker و images في هاذ السياق هوما images ديال أبليكاسيونات ديالنا لي تانصايبو. 13 |
  • 14 |
15 | 16 |
    17 |
  • الخيار الثاني هو تانستعملو docker باش نصايبو واحد الوسط مناسب (يعني فيه libs و dependencies لي بغينا) فين نrun'ew شي commands و شي Applications ديالنا.
    18 | هنا كانهضرو على images بحال ديال gnu/linux distro ولا ديال programming ecosystems بحال python أو node.js ....
    19 | في هاذ الحالة image ديالنا ماتاتكونش مراد منها تكون package و لكن تاتكون ecosystem .. و هاذشي لي تايخليها ماتايكونش عندها Entrypoint واحد مفروض على user في runtime .. و لكن بالعكس تايكون مطلوب منها تكون قادرة تexecute واحد العدد ديال commands aka CMD
    20 | في هاذ الUsecase تايكون ممكن لينا نحددوا CMD في الBuild و لكن ماتاتكونش مفروضة علينا في الRun و تايمكن لينا نبدلوها بسهولة
    21 | دابا من بعد ما هضرنا على ENTRYPOINT و CMD و الفرق بيناتهم و Motivation ديال كل واحدة .. آجي نشوفو كيفاش نخدموهم.
    22 | عمليا، ENTRYPOINT و CMD عندهم نفس المفعول في أغلب الحالات.. الفرق هو أن CMD ممكن تبدلوها بcommand لي بغينا في Runtime 23 |
  • 24 |
25 | 26 | # dockerfile 27 | ... 28 | ENTRYPOINT ["node", "devc.rabat.js"] 29 | ... 30 | # --- 31 | 32 | # this will run the devc rabat node application. 33 | docker run -it devc:rabat 34 | 35 |
36 | نفس المثال بCMD 37 |
38 | 39 | # dockerfile 40 | ... 41 | CMD ["node", "devc.rabat.js"] 42 | ... 43 | # --- 44 | 45 | # this will run the devc rabat node application. 46 | docker run -it devc:rabat 47 | # but this will run the devc casa node application. 48 | docker run -it node devc.casa.js 49 | 50 |
51 | واحد من usecases الزوينين لCMD هو نستعملوها باش ندوزو Parameters لENTRYPOINT ديالنا مادام المحتوى ديال CMD دائما تايتزاد في الأخير (هاذ اللعيبة تاتخدم في Exec form فقط) 52 |
53 | 54 | # dockerfile 55 | ... 56 | CMD ["--help"] 57 | ENTRYPOINT ["node", "devc.js"] 58 | ... 59 | # --- 60 | 61 | # this will display the help message for our app 62 | docker run -it devc:rabat 63 | # this will run our app with awesome argument. 64 | docker run -it devc:rabat awesome 65 | 66 | --- 67 |
ملاحظات: 68 |
    69 |
  • حتى ENTRYPOINT ممكن نبدلوه في Runtime باستعمال entrypoint-- و لكن غير منصوح بيها حيث غانكون تانبدلو الهوية ديال container بحد ذاتها
  • 70 |
  • كنت بغيت نهضر على One process per container Philosophy و كيفاش تاتأثر في Design ديال Dockerfiles و CMD و ENTRYPOINT و لكن تايبان لي غادي نخليوها لمرة أخرى
  • 71 |
72 |
-------------------------------------------------------------------------------- /images/docker-ps-filtering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/docker-ps-filtering.png -------------------------------------------------------------------------------- /images/docker-ps-formatting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/docker-ps-formatting.png -------------------------------------------------------------------------------- /images/layers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/layers.jpg -------------------------------------------------------------------------------- /images/lifecycle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/lifecycle.jpg -------------------------------------------------------------------------------- /images/oci-image-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/oci-image-1.jpg -------------------------------------------------------------------------------- /images/oci-image-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/oci-image-2.jpg -------------------------------------------------------------------------------- /images/terminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Iduoad/30DaysOfDocker/0c42328558302490226e53673884e34228e66a5f/images/terminal.jpg --------------------------------------------------------------------------------