Skip to content

Commit 0ef909f

Browse files
committed
Fix the table of contents
1 parent 87b367a commit 0ef909f

1 file changed

Lines changed: 31 additions & 35 deletions

File tree

content/posts/cpp_proj_template.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,40 @@ tags = ["cpp","docker"]
88
+++
99

1010
# Table of Contents
11-
```
1211
1. [Intro](#intro)
13-
2. [Part 1 - Docker Overview](#part-1---docker-overview)
12+
2. [Part 1 - Docker Overview](#part-1-docker-overview)
1413
1. [Understanding Docker](#understanding-docker)
1514
- [Docker vs Virtual Machine](#docker-vs-virtual-machine)
1615
- [Key Components of Docker](#key-components-of-docker)
1716
- [Linux Mechanisms Leveraged by Docker](#linux-mechanisms-leveraged-by-docker)
1817
- [Diagrams of Docker Environment on Linux](#diagrams-of-docker-environment-on-linux)
19-
2. [Understanding Differences between Container Technologies - Docker, LXC, and OCI](#understanding-differences-between-container-technologies---docker-lxc-and-oci)
18+
2. [Understanding Differences between Container Technologies - Docker, LXC, and OCI](#understanding-differences-between-container-technologies-docker-lxc-and-oci)
2019
- [Docker](#docker)
2120
- [LXC (Linux Containers)](#lxc-linux-containers)
2221
- [OCI (Open Container Initiative)](#oci-open-container-initiative)
2322
- [Comparison Table: Docker, LXC, and OCI](#comparison-table-docker-lxc-and-oci)
24-
3. [Setting Up Docker for C/C++ Development](#setting-up-docker-for-cc-development)
25-
1. [Installing Docker on Your Development Machine](#installing-docker-on-your-development-machine)
26-
2. [Basics of Dockerfile](#basics-of-dockerfile)
27-
3. [Creating a Docker Image for C/C++ Development](#creating-a-docker-image-for-cc-development)
23+
3. [Setting Up Docker for C/CPP Development](#setting-up-docker-for-c-cpp-development)
24+
- [Installing Docker on Your Development Machine](#installing-docker-on-your-development-machine)
25+
- [Basics of Dockerfile](#basics-of-dockerfile)
26+
- [Creating a Docker Image for C/CPP Development](#creating-a-docker-image-for-c-cpp-development)
2827
4. [Useful Docker Client Commands](#useful-docker-client-commands)
2928
5. [Managing Dependencies](#managing-dependencies)
3029
6. [Streamlining Build Processes](#streamlining-build-processes)
31-
1. [Automating the Build Process using Dockerfile and Docker Compose](#automating-the-build-process-using-dockerfile-and-docker-compose)
32-
2. [Handling Different Build Configurations within Docker](#handling-different-build-configurations-within-docker)
30+
- [Automating the Build Process using Dockerfile and Docker Compose](#automating-the-build-process-using-dockerfile-and-docker-compose)
31+
- [Handling Different Build Configurations within Docker](#handling-different-build-configurations-within-docker)
3332
7. [Collaboration and Deployment](#collaboration-and-deployment)
34-
1. [Sharing Docker Images for Consistent Development Environments](#sharing-docker-images-for-consistent-development-environments)
35-
2. [Deploying C/C++ Applications using Docker Containers in Production Environments](#deploying-cc-applications-using-docker-containers-in-production-environments)
33+
- [Sharing Docker Images for Consistent Development Environments](#sharing-docker-images-for-consistent-development-environments)
34+
- [Deploying C/CPP Applications using Docker Containers in Production Environments](#deploying-c-cpp-applications-using-docker-containers-in-production-environments)
3635
8. [Best Practices and Tips](#best-practices-and-tips)
37-
1. [Optimizing Dockerfiles for Efficiency](#optimizing-dockerfiles-for-efficiency)
38-
2. [Managing Container Resources Effectively](#managing-container-resources-effectively)
39-
3. [Securing Docker Containers for C/C++ Projects](#securing-docker-containers-for-cc-projects)
40-
9. [Debugging C/C++ Applications using GDB](#debugging-cc-applications-using-gdb)
36+
- [Optimizing Dockerfiles for Efficiency](#optimizing-dockerfiles-for-efficiency)
37+
- [Managing Container Resources Effectively](#managing-container-resources-effectively)
38+
- [Securing Docker Containers for C/CPP Projects](#securing-docker-containers-for-c-cpp-projects)
39+
9. [Debugging C/CPP Applications using GDB](#debugging-c-cpp-applications-using-gdb)
4140
10. [Docker Containers vs Native Builds](#docker-containers-vs-native-builds)
4241
11. [Multi-Architecture Builds](#multi-architecture-builds)
4342
12. [Docker Container Runtime Management](#docker-container-runtime-management)
44-
3. [Part 2 - My Dockerized C/CPP Environment](#part-2---my-dockerized-ccpp-environment)
45-
1. [Configuring My C/CPP Development Environment](#configuring-my-ccpp-development-environment)
43+
3. [Part 2 - My Dockerized C/CPP Environment](#part-2-my-dockerized-c-cpp-environment)
44+
1. [Configuring My C/CPP Development Environment](#configuring-my-c-cpp-development-environment)
4645
2. [Features and Usage](#features-and-usage)
4746
- [Build Images and Apps for Different Architectures](#build-images-and-apps-for-different-architectures)
4847
- [Running the Container](#running-the-container)
@@ -52,8 +51,6 @@ tags = ["cpp","docker"]
5251
- [Scanning the Image and Linting the Dockerfile](#scanning-the-image-and-linting-the-dockerfile)
5352
- [Profiling](#profiling)
5453
4. [Conclusion](#conclusion)
55-
```
56-
5754

5855

5956
# Intro
@@ -262,11 +259,11 @@ To better understand the distinctions and similarities between Docker, LXC, and
262259
*Table 1: Comparison of Docker, LXC, and OCI*
263260

264261

265-
## Setting Up Docker for C/C++ Development
262+
## Setting Up Docker for C/CPP Development
266263

267-
Setting up Docker for C/C++ development involves installing Docker on your development machine, understanding the basics of Dockerfile for defining the development environment, and creating a Docker image tailored for C/C++ development.
264+
Setting Up Docker for C/CPP Development involves installing Docker on your development machine, understanding the basics of Dockerfile for defining the development environment, and creating a Docker image tailored for C/C++ development.
268265

269-
**Installing Docker on Your Development Machine:**
266+
### Installing Docker on Your Development Machine
270267

271268
First, you need to install Docker on your development machine. There are different ways to install Docker, depending on your operating system.
272269

@@ -278,7 +275,7 @@ First, you need to install Docker on your development machine. There are differe
278275

279276
Follow the instructions provided on the [Docker Engine website](https://docs.docker.com/engine/install/) to install Docker Engine on your Linux distribution.
280277

281-
**Basics of Dockerfile:**
278+
### Basics of Dockerfile
282279

283280
Create a new directory for your C/C++ project and navigate into it:
284281

@@ -325,7 +322,7 @@ In this Dockerfile:
325322
- `WORKDIR`: Sets the working directory within the container.
326323
- `COPY`: Copies the local project files into the container.
327324

328-
**Creating a Docker Image for C/C++ Development:**
325+
### Creating a Docker Image for C/CPP Development
329326

330327
Once you've created the Dockerfile, you can build the Docker image using the `docker build` command. Run the following command in your project directory:
331328

@@ -503,7 +500,7 @@ By managing dependencies effectively and specifying precise versions within your
503500

504501
## Streamlining Build Processes
505502

506-
1. **Automating the Build Process using Dockerfile and Docker Compose:**
503+
### Automating the Build Process using Dockerfile and Docker Compose
507504
Docker Compose can be employed for orchestrating multi-container applications and defining complex build configurations.
508505
Let's consider a scenario where you have a C/C++ project consisting of multiple services, such as a web server and a database. We'll compare how you would use Docker Compose and Docker run commands to manage these services.
509506

@@ -561,7 +558,7 @@ In this example:
561558

562559
In summary, Docker Compose offers a more streamlined and maintainable approach for managing multi-container applications, while Docker run commands are suitable for simpler scenarios or quick ad-hoc deployments.
563560

564-
2. **Handling Different Build Configurations within Docker:**
561+
## Handling Different Build Configurations within Docker
565562
- Use environment variables or build arguments in Dockerfile to handle different build configurations (e.g., Debug vs. Release).
566563
- Customize build commands based on the selected configuration.
567564

@@ -580,7 +577,7 @@ In summary, Docker Compose offers a more streamlined and maintainable approach f
580577
## Collaboration and Deployment
581578
Collaboration and deployment are crucial stages in the software development lifecycle. Docker provides a robust platform for sharing development environments across teams and deploying C/C++ applications consistently in production environments. Here's how you can leverage Docker for collaboration and deployment:
582579
583-
1. **Sharing Docker Images for Consistent Development Environments:**
580+
### Sharing Docker Images for Consistent Development Environments
584581
- Build Docker images containing your C/C++ development environment, including dependencies, libraries, and tools.
585582
- Share these Docker images via a Docker registry or repository, ensuring consistency across development teams.
586583
@@ -593,7 +590,7 @@ Collaboration and deployment are crucial stages in the software development life
593590
594591
Team members can pull the shared Docker image to set up their development environments quickly and reliably.
595592
596-
2. **Deploying C/C++ Applications using Docker Containers in Production Environments:**
593+
### Deploying C/CPP Applications using Docker Containers in Production Environments
597594
- Package your C/C++ applications into Docker containers, along with necessary dependencies and configurations.
598595
- Deploy these Docker containers to production environments, ensuring consistency and portability across different infrastructure setups.
599596
@@ -608,7 +605,6 @@ By leveraging Docker for collaboration and deployment, development teams can str
608605
609606
610607
## Best Practices and Tips
611-
612608
Optimizing Dockerfiles, managing container resources, and securing Docker containers are essential aspects of using Docker effectively for C/C++ projects. Here are some best practices and tips:
613609
614610
1. **Optimizing Dockerfiles for Efficiency:**
@@ -621,7 +617,7 @@ Optimizing Dockerfiles, managing container resources, and securing Docker contai
621617
- Monitor container resource usage using Docker metrics and adjust resource limits accordingly to optimize resource utilization.
622618
- Consider using orchestration tools like Docker Swarm or Kubernetes for managing containerized applications at scale, enabling efficient resource allocation and scheduling.
623619
624-
3. **Securing Docker Containers for C/C++ Projects:**
620+
3. **Securing Docker Containers for C/CPP Projects:**
625621
- Update Docker base images and dependencies regularly to patch known vulnerabilities and ensure the security of your containers.
626622
- Implement least privilege principles by running containers with non-root users and restricting container capabilities using Docker security features.
627623
- Enable Docker Content Trust (DCT) to ensure the integrity and authenticity of images by verifying image signatures before pulling and running them.
@@ -687,7 +683,7 @@ Examples:
687683
docker stack deploy -c docker-compose.yml my_stack
688684
```
689685
690-
### Securing Docker Containers for C/C++ Projects:
686+
### Securing Docker Containers for C/CPP Projects:
691687
692688
1. **Updating Docker Base Images:**
693689
```bash
@@ -713,7 +709,7 @@ Examples:
713709
docker logs my_container
714710
```
715711
716-
## Debugging CPP apps using GDB
712+
## Debugging C/CPP Applications using GDB
717713
718714
You can use GDB's remote debugging feature to debug your C/C++ applications running inside a Docker container from a host machine. Here's how you can achieve that:
719715
@@ -772,7 +768,7 @@ This table provides a concise comparison between Docker containers and native bu
772768
| **Dependency Management** | Encapsulates dependencies within a self-contained environment. | Relies on system-wide dependencies, requiring careful management. |
773769
774770
775-
## Multi architectures builds
771+
## Multi Architecture Builds
776772
This example demonstrates how to build a simple "Hello, World!" C++ application for both amd64 and arm64 architectures using Docker buildx. The resulting Docker image can be run on systems with different CPU architectures without modification, showcasing the versatility and compatibility of Docker multi-architecture builds. (Demo: [HERE](https://github.com/luk6xff/luk6xff.github.io/tree/master/content/other/code/cpp_proj_template)):
777773
778774
1. **Create a C++ source file** (hello.cpp):
@@ -1231,7 +1227,7 @@ cmake --build build -t codechecker
12311227
# Goto http://localhost:8999/Default/runs
12321228
```
12331229
1234-
### Unitests
1230+
### Unit Tests
12351231
```sh
12361232
./run.sh -u -amd64
12371233
# UnitTests Report
@@ -1281,7 +1277,7 @@ In conclusion, Docker containerization offers a powerful solution for simplifyin
12811277
12821278
Throughout this guide, we've explored various aspects of Docker container management, including:
12831279

1284-
- Setting up Docker for C/C++ development, including installing Docker and creating Dockerfiles.
1280+
- Setting Up Docker for C/CPP Development, including installing Docker and creating Dockerfiles.
12851281
- Configuring development environments within Docker containers, including installing compilers, build tools, and debugging utilities.
12861282
- Managing dependencies and incorporating third-party libraries into Docker images.
12871283
- Streamlining build processes using Dockerfile and Docker Compose.

0 commit comments

Comments
 (0)