Docker Combat Guide
$15.00
Minimum price
$25.00
Suggested price

Docker Combat Guide

The Docker Guide for Software Developers

About the Book

First published : 2021-09-10

Current version: 2022-06-21 v.23

A 175 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.

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 persistance.

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

Updates

2022-04-25 v.22

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

$90.00
Suggested price
$42.00
Bundle Price

Table of Contents

  • Index v.20 (2022-02-15)...........................................................................2
  • Dedication.......................................................................5
  • Contact me.......................................................................6
  • Receiving Free Updates.............................................................6
  • If you’re not satisfied..............................................................6
  • Conventions......................................................................7
  • Knowing what version are you using – docker version....................................8
  • Creating our first Container..........................................................9
  • Our first Dockerfile..............................................................9
  • Running our first Container based in a Dockerfile.....................................10
  • docker ps -a...................................................................10
  • Running a Container that does something and exits......................................11
  • Naming the images with -t (tagging)...............................................11
  • docker images.................................................................12
  • Running a container by its name..................................................14
  • Have a cheap Ubuntu in your Windows or Mac with Docker...............................16
  • docker ps.....................................................................21
  • A simple web Hello World in Flask...................................................22
  • A small CLI Python + MySql + Docker program as a sample..............................26
  • Installing the MySql driver.......................................................27
  • Dockerfile....................................................................28
  • build_docker.sh................................................................29
  • docker_run.sh.................................................................29
  • docker_run_mysql.sh...........................................................30
  • start.sql......................................................................31
  • select_values_example.py.......................................................32
  • Executing the Container.........................................................32
  • Entering the Container and running the code.........................................34
  • Tying together MySQL and a Python Menu with Object Oriented Programming.............34
  • MySQL Library...............................................................35
  • A Data Object: CarDO..........................................................36
  • Queue Manager................................................................38
  • Bonus.......................................................................44
  • A Dockerfile with PHP, Apache and Catalonia Frameworks...............................45
  • End of life of images............................................................46
  • Create the Dockerfile...........................................................46
  • The www.cataloniaframework.com.conf file.........................................49
  • Stopping, starting the docker Service and creating the Catalonia image....................50
  • Building with --no-cache option...................................................50
  • Trying the Container working.....................................................51
  • 2 / 178A base Dockerfile for your Jenkins deployments........................................53
  • The EXPOSE instruction........................................................56
  • Build the Container.............................................................56
  • Run the Container displaying the password..........................................56
  • Mapping the ports with -p........................................................57
  • Configure Jenkins with Projects and Pipelines........................................60
  • Why I propose you to use Python 3.8, at least, for your Internal Automation Tools in Docker
  • Containers and Ubuntu LTS........................................................61
  • Reliability and Maturity.........................................................61
  • A sample Star Wars Python 3 Flask Applications........................................63
  • MT Notation..................................................................67
  • The Dockerfile for flask.........................................................67
  • Installing PIP3 Requirements with pip3 install -r requirements.txt........................68
  • Defining Environment Variables in the Container with ENV............................68
  • File requirements.txt............................................................69
  • build_docker.sh................................................................69
  • Refreshing settings in a Docker immutable image with Python and Flask.....................70
  • Smaller Images................................................................73
  • Using Docker for Unit Testing......................................................74
  • Using Docker for running a demo....................................................74
  • Making a Container start automatically...............................................76
  • Docker Volumes.................................................................77
  • Launch a Container using a specific Volume.........................................78
  • Docker compose.................................................................79
  • Docker-compose with LAMP and PHPMyAdmin.......................................85
  • Volumes.....................................................................88
  • Exporting and Importing Docker Images..............................................89
  • Docker container ls -a.............................................................90
  • Cleaning what you don’t use: docker system prune......................................90
  • DockerHub.....................................................................91
  • Docker information...............................................................96
  • Limit containers resources..........................................................97
  • Limit the Memory of the Containers..................................................97
  • Limit the CPU for the Containers....................................................97
  • Adding an additional user, so you don’t have to run as root................................98
  • Checking the logs from a Container.....................................................99
  • Communicating with Docker Containers via Linux Signals and Python – docker kill...........99
  • The Dockerfile...............................................................100
  • The dockersignal.py file........................................................100
  • build_and_run_docker.sh.......................................................101
  • Tools and Tricks...................................................................103
  • Reverse Engineering a Docker image to get the founding Dockerfile (dfimage)...............103
  • Lazy Docker...................................................................107
  • ctop..........................................................................109
  • CTOP.py......................................................................110
  • Using Docker in Windows 10 without Windows Desktop with Docker Engine and without WSL.111
  • 3 / 178Installing Docker Command line binaries..........................................112
  • Turn Windows features on or off.................................................113
  • Enable Experimental Mode.....................................................114
  • Switch Daemon...............................................................115
  • Troubleshooting...................................................................117
  • Troubleshooting a failing Docker Container...........................................117
  • Solving the problem when running an Alpine Docker Container: standard_init_linux.go:190: exec
  • user process caused “no such file or directory”.........................................117
  • A typical copy and paste error......................................................119
  • Running out of space.............................................................120
  • Space taken from Images.......................................................120
  • Space taken from logs..........................................................120
  • Using the Docker SDK.............................................................124
  • MT Notation...................................................................124
  • Installing the requirements........................................................124
  • The most basic examples..........................................................125
  • Run a Container..............................................................125
  • Run a Container in Background..................................................125
  • Pull an Image................................................................125
  • List the Containers............................................................126
  • Videos........................................................................132
  • Docker SDK from Python demo (7m 55secs).......................................132
  • Docker-compose up demo (4m 10secs)............................................132
  • Docker SDK Demo Python 3 program.................................................136
  • Running the program.............................................................136
  • Setting PyCharm................................................................137
  • To Run the demo from command line.............................................142
  • First look at the code...........................................................147
  • List Containers (first version)......................................................149
  • Run the Container ubuntu:latest with echo hello world (bonus)............................151
  • Running a Container.............................................................152
  • Reverse Engineering to get what I need..............................................156
  • List of all Containers (pretty version)................................................159
  • Stop a Container................................................................161
  • Deleting all the stopped Containers..................................................165
  • Finding the prune equivalent.......................................................166
  • Writing a Dockerfile and running the Container........................................168
  • The docker-compose project.......................................................174
  • Recommended bibliography.........................................................178
  • Official Docker Documentation....................................................178
  • Python Docker SDK.............................................................178
  • Books.........................................................................178

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.

See full terms

Do Well. Do Good.

Authors have earned$11,712,765writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

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), EPUB (for phones and tablets) and MOBI (for 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, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub