C++ and Docker: Containerizing Applications
300 pages
English
PDF
4.5

C++ and Docker: Containerizing Applications

C++ and Docker: Containerizing Applications

Author:

Year:

Summary:

The book "C++ and Docker: Containerizing Applications" is the first practical guide of its kind that bridges the gap between classical C++ development and modern DevOps practices. Whether you are a C++ developer looking to simplify building, testing, and deploying your projects, or a DevOps engineer faced with the need to containerize legacy C++ code — this book is for you.



Unlike popular Docker guides for web applications (Python, Node.js, Go), C++ has specific requirements: static and dynamic linking, system library management, image size optimization, and working with CMake and Vcpkg. The author thoroughly examines all these aspects, offering ready-made recipes and Dockerfile templates.



What you will learn from the book:

  • Docker Basics for C++: how containerization of compiled languages differs from interpreted ones, and how to avoid common mistakes (e.g., glibc issues).
  • Multi-stage builds: how to build an application in one image and send a minimal artifact to production without the compiler and header files.
  • Dependency Management: integrating Docker with Conan, Vcpkg, and CMake. How to cache libraries to avoid rebuilding them on every commit.
  • DevContainers and VSCode: setting up a development environment in a container so the entire team works in identical conditions.
  • CI/CD Pipelines: automating builds, linking, static analysis, and unit tests inside Docker using GitHub Actions and GitLab CI.
  • Image Size Optimization: how to reduce the final image from 2 GB to 50 MB using Alpine, Scratch, and static compilation.
  • Production Deployment: running C++ microservices in Docker Swarm and Kubernetes, working with health checks and graceful shutdown.
  • Security: vulnerability scanning, running containers with limited privileges, using read-only file systems.


Who this book is for:

  • C++ developers who want to integrate Docker into their workflow.
  • DevOps engineers who need to support building and deploying C++ applications.
  • Students and educators studying modern software development methodologies.
  • Tech leads planning to migrate a C++ monolith to a microservice architecture.


All examples in the book are based on real projects and are accompanied by complete code available in the repository. You will learn not just to run "Hello World" in a container, but to build a reliable, reproducible, and scalable process from development to production.



The book is suitable for readers with a basic knowledge of C++ and a beginner's understanding of Docker. If you can write simple programs in C++ and have ever run docker run, that is enough to get started.

Recommendations