Docker Combat Guide
$17.00
Minimum price
$27.00
Suggested price

Docker Combat Guide

The Docker Guide for Software Developers

About the Book

First published : 2021-09-10

Current version: 2022-07-27 v.29

A 197 Full-size DIN-A4 size pages in PDF format, DRM-free, super effective for Developers in order to learn by examples how to use Docker (70% of the book) and Docker SDK for Python 3 (20%).

Docker allows you to run identical environment in Development that in Production.

Docker allows you to work with images that are equal in all you Servers, are immutable. If one works bad, you simply kill that Container and start another, new.

Docker is also very System Administrator, DevOps and SRE oriented, as it requires a lot of Linux understanding, so if you're a Software Developer you may not know how powerful it is.

This guide is created specifically for Software Developers in Python, PHP, Java, that want to discover the power of Docker Containers with easy examples. Although most of the examples use Python.

It covers creating Docker in workstations running:

  • Ubuntu Linux
  • Windows
  • Mac OS X

This is not an extensive guide for System Administrators, DevOps and SREs.

This is a guide for Developers that want to start using Docker super quickly, by using examples from different projects. Also explains the usage of docker-compose and the Volumes and bind mounts for persistence.

The guide offers source code and the link to a repository, so you can just clone the code from there.

Updates

2022-07-29 v.27

  • Automatically restart the Containers
  • Added a Docker Container example with RabbitMQ and Python using it with package pika

2022-07-25 v.25

  • Show how to install Jenkins with plugin Blue Ocean for Pipelines and persistent Volumes
  • Show usage of USER command in Dockerfile
  • Explaining WORKDIR
  • Explaining ARG
  • Explaining ENV
  • Overriding ENV variables from Command Line
  • Overriding or setting ENV variables from Command Line using a file and the argument --env-file

2022-07-03 v.24

How to use different users in Dockerfile and in Interactive Sessions.

Showing how to run a jenkins containerized.

2022-06-21 v.23

Explained differences between docker export and save.

Fixed a typo referring to docker ls instead of docker ps.

Show how to use docker logs.

2022-04-25 v.22

Updated Dockerfile for packages being updated and asking for interactive input.

Display how to install ping and ssh client and interact to Windows and Mac hosts from inside the Docker Container by using host.docker.internal.

2022-02-15 v.20

Added some tricks, like clearing the logs, using some tools, and using Docker in Windows from command line without activating Docker Desktop.

2022-01-20 v.19

Full Source code of the SDK sample Python 3 demo application uploaded to Extras.

2021-11-24 v.18

Added the usage of a Software to reverse engineering an image and getting the original Dockerfile.

Added a typical copy and paste error to Troubleshoot section.

About the Author

Carles Mateo
Carles Mateo

I’m Carles Mateo, since January 2020 working as Operations Engineer for Blizzard Entertainment in Cork, Ireland.

Previously worked as Cloud Architect and SDM for Sanmina, in Ireland and United States, where I created and I did lead a Python and C project for a Storage Manager for our 4U Cold Storage Servers 1PB and 2U SSD and 1U NVMe with NICs up to 2x100Gbps, which will restore redundancy in the RAID when a drive dies, very quickly, using ZFS and DRAID.

I helped several multinationals:

  • Volkswagen IT (gedas) where I got promoted to head of department of Reusability and Code Components and previously I lead the SEAT's Intranet project, I solved TCP/Ip transmission problems in project PortIc for Barcelona's port (EDI Transfer), I created a project to transfer warranty documents over Web and TCP/IP instead of X.25 expensive lines, and worked for CaixaBank (formerly "la caixa") creating a Documentum solution programing the GUI and DLL's.
  • Winterthur Insurance (Axa) where I was Senior PM and I lead both technically and in functionally, the project to deploy a new Contact Center Software, the e-Commerce web platform and the insurance of health policies (special Data treatment)
  • BBVA Tickets where I was responsible of the platform (Sun Solaris and Oracle)

I worked a lot for CSP (Cloud Service Providers) and ISP, in Linux.

Also I helped many Start ups, e-Commerces, Online travel agencies... as CTO or in hands on positions leading teams and coding myself, in Software Development, SRE and Operation roles.

I was one of the 5 Senior BackEnds that wrote Privalia's new multi-country Website, from the scratch, with inheritance, and I lead a KPI Dashboards for CEO, really learning the internals of all the areas of the company through the data.

The last company I was CTO for, in Barcelona, was sold to airbnb for 45 million euros.

My friends say that everything I touch turns into gold, and my very good friend Jaume (R.I.P.) used to say that I was the most brutal technical guy, solving all the difficult technical issues easily, that he ever met. I've very grateful thoughts and memories for all the people that did speak up how well they considered me, and that were fair Other people tried to take advantage by never telling me how good and helpful I was, so they could pay me less. What they didn't know is that I always had offers paying me double, and I was choosing to help them.

Now I only accept fair agreements. I know my value.

I started programming when I was 5 years old, at 10 I won a contest at Spanish State level, getting a Pc with a green phosphorescent monitor and a floppy drive, and I've lived the times of the BBS, much before Internet.

I've coded many Freeware Software, and Open Source Software, and I created the first system in Europe to sell Tickets for musical events, in 1995, for Tick Tack Ticket. I created this e-Commerce engine, with render template system completely in C, cgi-bin, HTML.

I love Software and Hardware.

I've worked with C, Java, PHP, Python... and my knowledge of PHP Unit Testing really reached its best when I was working for a bank.

I've invented the CSort algorithm.

In my free time I teach some students to get pro in coding. Most of my time now I work with Python 3, Docker Containers and Linux.

You can find information about me in my blog.

https://blog.carlesmateo.com/bio

Bundles that include this book

$92.00
Bought separately
$42.00
Bundle Price

Table of Contents

  • Table of Contents
  • Index v. 25.......................................................................2
  • Dedication.......................................................................6
  • Contact me.......................................................................7
  • Receiving Free Updates.............................................................7
  • If you’re not satisfied..............................................................7
  • Conventions......................................................................8
  • Knowing what version are you using – docker version....................................9
  • Creating our first Container.........................................................10
  • Our first Dockerfile.............................................................10
  • Running our first Container based in a Dockerfile.....................................11
  • docker ps -a...................................................................11
  • Running a Container that does something and exits......................................12
  • Naming the images with -t (tagging)...............................................12
  • docker images.................................................................13
  • Running a container by its name..................................................15
  • Have a cheap Ubuntu in your Windows or Mac with Docker...............................17
  • What you do if you get stuck in a message asking for choosing a geographic tzdata region?....22
  • Dockerfile directive ARG........................................................23
  • Dockerfile directive ENV........................................................23
  • Setting and ENV value from an ARG value in the Dockerfile............................24
  • Overriding ENV variables from Command Line......................................24
  • Overriding or setting ENV variables from Command Line with a file and argument --env-file..25
  • docker ps.....................................................................27
  • Connecting to the Host from a Docker Container........................................28
  • Connecting to a Windows/Mac Host from a Docker Container as if it was localhost............29
  • A simple web Hello World in Flask...................................................32
  • WORKDIR...................................................................35
  • A small CLI Python + MySql + Docker program as a sample..............................36
  • Installing the MySql driver.......................................................37
  • Dockerfile....................................................................38
  • build_docker.sh................................................................39
  • docker_run.sh.................................................................39
  • docker_run_mysql.sh...........................................................40
  • start.sql......................................................................41
  • select_values_example.py.......................................................42
  • Executing the Container.........................................................42
  • Entering the Container and running the code.........................................44
  • Tying together MySQL and a Python Menu with Object Oriented Programming.............44
  • MySQL Library...............................................................45
  • A Data Object: CarDO..........................................................46
  • Queue Manager................................................................48
  • Bonus.......................................................................54
  • A Dockerfile with PHP, Apache and Catalonia Frameworks...............................55
  • End of life of images............................................................56
  • Create the Dockerfile...........................................................56
  • The www.cataloniaframework.com.conf file.........................................59
  • Stopping, starting the docker Service and creating the Catalonia image....................60
  • Building with --no-cache option...................................................60
  • Trying the Container working.....................................................61
  • A base Dockerfile for your Jenkins deployments........................................63
  • The EXPOSE instruction........................................................66
  • Build the Container.............................................................66
  • Run the Container displaying the password..........................................66
  • Mapping the ports with -p........................................................67
  • Configure Jenkins with Projects and Pipelines........................................70
  • Install jenkins on Docker with Blue Ocean and persisten Voluemes in Ubuntu 20.04 LTS........71
  • Usage of USER Command.......................................................72
  • Why I propose you to use Python 3.8, at least, for your Internal Automation Tools in Docker
  • Containers and Ubuntu LTS........................................................76
  • Reliability and Maturity.........................................................76
  • A sample Star Wars Python 3 Flask Applications........................................78
  • MT Notation..................................................................82
  • The Dockerfile for flask.........................................................82
  • Installing PIP3 Requirements with pip3 install -r requirements.txt........................83
  • Defining Environment Variables in the Container with ENV............................83
  • File requirements.txt............................................................84
  • build_docker.sh................................................................84
  • Refreshing settings in a Docker immutable image with Python and Flask.....................85
  • Smaller Images................................................................88
  • Using Docker for Unit Testing......................................................89
  • Using Docker for running a demo....................................................89
  • Making a Container start automatically...............................................91
  • Docker Volumes.................................................................92
  • Launch a Container using a specific Volume.........................................93
  • Launching a Container with a bind mount (local folder)..................................94
  • Docker compose.................................................................98
  • Docker-compose with LAMP and PHPMyAdmin......................................104
  • Volumes....................................................................107
  • Port collision.................................................................107
  • Exporting and Importing Docker Images.............................................108
  • Docker logs..................................................................109
  • Docker container ps -a............................................................110
  • Cleaning what you don’t use: docker system prune.....................................110
  • DockerHub.....................................................................111
  • Docker information..............................................................116
  • Limit containers resources.........................................................117
  • Limit the Memory of the Containers.................................................117
  • Limit the CPU for the Containers...................................................117
  • Adding an additional user, so you don’t have to run as root...............................118
  • Using a different user in the Containers.................................................119
  • Launching a jenkins Docker Container...............................................120
  • Checking the logs from a Container....................................................124
  • Communicating with Docker Containers via Linux Signals and Python – docker kill..........124
  • The Dockerfile...............................................................125
  • The dockersignal.py file........................................................125
  • build_and_run_docker.sh.......................................................126
  • Tools and Tricks...................................................................128
  • Reverse Engineering a Docker image to get the founding Dockerfile (dfimage)...............128
  • Lazy Docker...................................................................132
  • ctop..........................................................................134
  • CTOP.py......................................................................135
  • Using Docker in Windows 10 without Windows Desktop with Docker Engine and without WSL. 136
  • Installing Docker Command line binaries..........................................137
  • Turn Windows features on or off.................................................138
  • Enable Experimental Mode.....................................................139
  • Switch Daemon...............................................................140
  • Troubleshooting...................................................................142
  • Troubleshooting a failing Docker Container...........................................142
  • Solving the problem when running an Alpine Docker Container: standard_init_linux.go:190: exec
  • user process caused “no such file or directory”........................................142
  • A typical copy and paste error......................................................144
  • If a Container does not start.......................................................145
  • Running out of space.............................................................146
  • Space taken from Images.......................................................146
  • Space taken from logs..........................................................146
  • Using the Docker SDK.............................................................150
  • MT Notation...................................................................150
  • Installing the requirements........................................................150
  • The most basic examples..........................................................151
  • Run a Container..............................................................151
  • Run a Container in Background..................................................151
  • Pull an Image................................................................151
  • List the Containers............................................................152
  • Videos........................................................................154
  • Docker SDK from Python demo (7m 55secs).......................................154
  • Docker-compose up demo (4m 10secs)............................................154
  • Docker SDK Demo Python 3 program.................................................155
  • Running the program.............................................................155
  • Setting PyCharm................................................................156
  • To Run the demo from command line.............................................159
  • First look at the code...........................................................162
  • List Containers (first version)......................................................164
  • Run the Container ubuntu:latest with echo hello world (bonus)............................166
  • Running a Container.............................................................167
  • Reverse Engineering to get what I need..............................................169
  • List of all Containers (pretty version)................................................172
  • Stop a Container................................................................174
  • Deleting all the stopped Containers..................................................177
  • Finding the prune equivalent.......................................................178
  • Writing a Dockerfile and running the Container........................................180
  • The docker-compose project.......................................................185
  • Recommended bibliography.........................................................189
  • Official Docker Documentation....................................................189
  • Python Docker SDK.............................................................189
  • Books.........................................................................189

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub