├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── imgs ├── Architecture-of-Docker.png ├── Docker-Bridge-Network.jpeg ├── Docker-Components.jpeg ├── Docker-Execution-Environment.jpeg ├── Docker-Storage.jpeg ├── Docker-Workflow.jpeg ├── Linux-Cgroups.jpeg ├── Linux-Container-Architecture-1.jpeg ├── Linux-Process-Namespace.jpeg ├── md.png └── vm_vs_containers.jpg ├── init_docker.sh └── srcs ├── .env ├── docker-compose.yml └── requirements ├── bonus ├── adminer │ └── Dockerfile ├── portainer │ └── Dockerfile ├── redis │ ├── Dockerfile │ └── tools │ │ └── conf.py └── static_web │ ├── Dockerfile │ ├── conf │ └── nginx.conf │ └── tools │ ├── index.html │ ├── script.js │ └── styles.css ├── mariadb ├── Dockerfile ├── conf │ └── 50-server.cnf └── tools │ └── script.py ├── nginx ├── Dockerfile └── conf │ └── nginx.conf └── wordpress ├── Dockerfile ├── conf └── wp-config.php └── tools └── script.py /.gitignore: -------------------------------------------------------------------------------- 1 | .env -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 oumaima-aarabe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | up: dir 2 | docker compose -f ./srcs/docker-compose.yml up --build 3 | 4 | upd: dir 5 | docker compose -f ./srcs/docker-compose.yml up --build -d 6 | 7 | dir: 8 | @mkdir -p /home/ouaarabe/data 9 | @mkdir -p /home/ouaarabe/data/wordpress 10 | @mkdir -p /home/ouaarabe/data/mariadb 11 | 12 | 13 | down: stop 14 | docker compose -f ./srcs/docker-compose.yml down --rmi all --volumes 15 | sudo rm -rf /home/ouaarabe/data/* 16 | 17 | stop: 18 | docker compose -f ./srcs/docker-compose.yml stop 19 | 20 | c ?= mariadb 21 | restart: 22 | docker restart ${c} 23 | 24 | prune: down 25 | docker system prune -af 26 | 27 | re: prune up 28 | 29 | network: 30 | docker network inspect inception 31 | 32 | exec: 33 | docker exec -it ${c} /bin/bash 34 | 35 | 36 | logs: 37 | cd ./srcs && docker compose logs ${c} 38 | 39 | volumes: 40 | docker volume ls 41 | 42 | v ?= mariadb_vol 43 | volumes_rm: 44 | docker volume rm ${v} 45 | 46 | vinspect: 47 | docker volume inspect ${v} 48 | 49 | .PHONY: up upd down stop restart exec logs prune re network volumes volumes_rm vinspect -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #
The Inception Project is a sophisticated web infrastructure, all running on the same Docker network, orchestrated using Docker and Docker Compose.
36 |NGINX manages incoming web traffic, serving static files directly and forwarding dynamic content requests to PHP-FPM, which processes PHP code from WordPress. WordPress uses Redis for caching frequently accessed data, enhancing performance by reducing database queries to MariaDB, which handles all content data storage and management. After PHP-FPM processes the request and retrieves data from Redis and MariaDB, the content is returned to NGINX for delivery to the user. Additionally, NGINX serves a Static Website for direct content delivery. Adminer provides database management for MariaDB, and Portainer oversees and monitors the Docker containers running these services. Docker volumes ensure persistent storage and efficient data management, all within a unified Docker network that facilitates seamless communication and operation across the entire system.
37 |Component | 44 |Role | 45 |
---|---|
NGINX | 48 |Acts as the web server and reverse proxy, handling incoming web requests efficiently. Serves static content and forwards dynamic content requests to PHP-FPM. Optimizes web performance and ensures secure connections through SSL/TLS configuration. | 49 |
WordPress with PHP-FPM | 52 |Forms the core of the dynamic content management system (CMS). PHP-FPM processes PHP scripts, enabling WordPress to generate dynamic web pages based on user interactions, templates, and plugins. Essential for serving personalized content to users. | 53 |
MariaDB | 56 |Serves as the relational database management system (RDBMS) for WordPress. Stores all structured data generated by WordPress, including posts, pages, comments, and settings. Ensures data persistence and integrity. | 57 |
Redis | 60 |Acts as an in-memory data structure store, used as a database, cache, and message broker. Enhances WordPress performance by caching frequently accessed data, reducing load times, and improving the overall user experience. | 61 |
Static Website | 64 |Represents a simple website hosted alongside the WordPress site. Demonstrates the capability to serve static content efficiently, showcasing the versatility of the NGINX server in handling different types of web content. | 65 |
Portainer | 68 |Provides a graphical interface for managing Docker containers, images, networks, and volumes. Simplifies the administration of the Docker environment, making it easier to monitor and manage the infrastructure components. | 69 |
Adminer | 72 |Introduces a web interface for database management, supporting operations such as viewing and editing databases, tables, and records. Complements MariaDB by providing an accessible way to interact with the database directly from a web browser. | 73 |
Virtualization involves creating virtual versions or representations of computing resources—such as servers, storage devices, operating systems (OS), or networks—that are abstracted from the underlying physical hardware. This abstraction allows for greater flexibility, scalability, and agility in managing and deploying resources. Essentially, it lets you run multiple virtual computers on a single physical machine, making it like having several computer-generated computers from one set of hardware and software.
81 | 82 |A hypervisor is software that enables the creation and management of virtual computing environments. It acts as a lightweight layer, either software or firmware, that sits between the physical hardware and the virtualized environments. This layer allows multiple operating systems to run concurrently on a single physical machine by abstracting and partitioning the underlying hardware resources—such as CPUs, memory, storage, and networking—and allocating them to the virtual environments. Essentially, the hypervisor serves as the middleman, channeling resources from your physical infrastructure to various virtual instances. Hypervisors are crucial to virtualization technology, enabling efficient utilization and management of computing resources.
84 | 85 |Virtual machines (VMs) are simulated computing environments that run on physical hardware. They enable multiple operating systems and applications to operate independently on a single physical server. Each VM functions as a separate computer, with its own operating system, resources (such as CPU, memory, and storage), and applications. VMs allow for efficient use of hardware resources, simplify system management, and provide increased flexibility in deployment and scalability.
87 | 88 |Containers are a form of virtualization that allows you to run applications in isolated environments. They package an application and its dependencies into a single unit that can run consistently across various computing environments. This ensures that the application will work the same way regardless of where it's deployed.
90 |Containers leverage several key Linux features to provide isolation and resource management. Here are the main features:
91 |In summary, containers use Linux features to provide isolation, resource management, and a consistent runtime environment for applications. This enables efficient, secure, and portable application deployment across different environments.
106 |Both VMs and containers provide isolated environments for running applications, but they achieve this isolation in different ways.
111 |Aspect | 114 |VMs | 115 |Containers | 116 |
---|---|---|
Isolation | 119 |VMs provide hardware-level isolation by virtualizing the entire physical machine. Each VM runs its own operating system and applications. | 120 |Containers provide process-level isolation by sharing the host OS kernel. They encapsulate the application and its dependencies, ensuring consistent runtime environments. | 121 |
Performance | 124 |VMs have higher overhead because they require running a separate OS for each VM. This can result in slower performance and increased resource usage. | 125 |Containers have lower overhead as they share the host OS kernel. They are lightweight and start up faster, offering better performance and resource efficiency. | 126 |
Portability | 129 |VMs are less portable as they depend on the underlying hypervisor and hardware compatibility. | 130 |Containers are highly portable because they include all necessary dependencies and can run on any system with a compatible container runtime. | 131 |
Resource Allocation | 134 |VMs allocate fixed amounts of resources (CPU, memory, storage) to each VM, which can lead to underutilization or overcommitment of resources. | 135 |Containers can dynamically share resources, allowing for better resource utilization and scalability. | 136 |
Management | 139 |VMs require managing separate OS instances, which can be complex and resource-intensive. | 140 |Containers simplify management by running on a shared OS kernel, reducing the need for managing multiple OS instances. | 141 |
Docker and LXC (Linux Containers) are both containerization technologies, but they have different focuses and use cases.
148 |Aspect | 151 |Docker | 152 |LXC | 153 |
---|---|---|
Focus | 156 |Application-centric: Docker is designed to package and run individual applications and their dependencies in isolated containers. | 157 |System-centric: LXC is designed to run full Linux systems in containers, making it suitable for running multiple processes and services. | 158 |
User Experience | 161 |Docker provides a higher-level, user-friendly interface and tooling for building, managing, and deploying containers. | 162 |LXC provides a lower-level interface, giving users more control over container configuration and management. | 163 |
Image Management | 166 |Docker has a robust image management system with Docker Hub, allowing for easy distribution and versioning of container images. | 167 |LXC does not have a centralized image repository, and image management is more manual and less standardized. | 168 |
Orchestration | 171 |Docker has strong support for container orchestration tools like Docker Compose, Kubernetes, and Swarm. | 172 |LXC has limited support for orchestration tools, making it less suitable for large-scale, complex deployments. | 173 |
Docker is a platform for developing, shipping, and running applications inside containers. It provides an efficient way to package applications with their dependencies, ensuring consistency across different environments.
180 |A Docker image is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, libraries, environment variables, and configuration files. Docker images are used to create containers, which are instances of the images that run the application.
185 |# Example of a Dockerfile for a simple web application
187 | FROM node:14
188 |
189 | # Set the working directory
190 | WORKDIR /app
191 |
192 | # Copy application code
193 | COPY . .
194 |
195 | # Install dependencies
196 | RUN npm install
197 |
198 | # Expose the application port
199 | EXPOSE 3000
200 |
201 | # Command to run the application
202 | CMD ["npm", "start"]
203 |
204 | Docker Compose is a tool for defining and running multi-container Docker applications. With Docker Compose, you can use a YAML file to configure your application's services, networks, and volumes. Then, with a single command, you can create and start all the services defined in the configuration.
210 |Docker volumes are used to persist data generated by and used by Docker containers. They provide a way to store data outside of the container's writable layer, ensuring data is not lost when containers are stopped or removed.
216 |# Example of creating a volume
218 | docker volume create my_volume
219 |
220 | # Example of using a volume in a container
221 | docker run -d -v my_volume:/data my_image
222 |
223 | Volumes are used to persist data generated by and used by Docker containers. There are different types of volumes:
228 |Docker volumes can be managed using various volume drivers and mount options to customize how they are created, accessed, and managed.
238 | 239 |Volume drivers allow Docker to integrate with various storage solutions. Some common volume drivers include:
241 |Docker supports different types of mounts:
251 |When defining volumes, you can specify various options to control their behavior:
259 |Docker provides several network types to manage how containers communicate with each other and with external systems:
270 |