Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Inception Project

Goal: Build a fully containerized WordPress + Nginx + MariaDB infrastructure from scratch using Dockerfiles and Docker Compose.

image

Key Takeways:

  • A container is an instance of an image
  • Container orchestration is a tool that helps manage multiple containers (e.g. Kubernetes)
  • Docker compose is a lightweight container orchestrator that can manage containers in a single host.
  • Container registry is where you can share a image or find images created by other people (e.g. AWS Elastic Container Registry).

Project structure:

project-root/
├── compose.yaml    # Defines and runs all containers (configures them)
├── .env            # Stores environment variables
├── nginx/          # Nginx service
├── wordpress/      # WordPress service
└── mariadb/        # MariaDB service

Containers

In the software field, a container is a lightweight, standalone, and executable package that includes everything needed to run a piece of software, including the code, runtime, system tools, libraries, and settings.

Containers share the host OS kernel but run in isolated environments. This makes them fast, efficient, and ideal for scaling applications. In contrast, setting up a virtual machine (VM) can take hours and requires a full operating system for each instance.

Untitled
  • Cgroups: Cgroups, or control groups, are a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, etc.) of a collection of processes.
  • Namespaces: Namespaces are a Linux kernel feature that isolates and virtualizes system resources for a set of processes, creating the appearance of a separate instance of the operating system.

How to re-create an environment on any new instance?

Container tecnology!

Docker

Docker is the most popular container tecnology that abstracts the complexities of namespaces and Cgroups.

oioidocker

Common Dockerfile Instructions

  • FROM – Specifies the base image to use.
  • RUN – Executes commands during the image build process.
  • CMD – Defines the default command to run when the container starts (similar to ENTRYPOINT).

Volumes

Volumes are used to persist data generated by containers. They store the data outside the container’s filesystem, so the data remains available even if the container stops, restarts, or is removed.

SSL/TLS

Encrypts the communication between the client and server.

Most used commands

docker ps                                #show containers that are running
docker compose ps                        #show containers and names of images
docker exec -it nginx /bin/bach          #enter inside the container
docker compose up                        #create multiple containers
docker rm $(docker ps -q -a)             #stops the containers -q returns the container's ID -a includes all containers and not only in execution
docker rm $(docker ps -qa)               #remove all containers from Docker
docker rmi -f $(docker images -qa)       #forces to remove all containers
docker volume rm $(docker volume ls -q)  #remove all volumes (same for networks)
docker network ls                        #remove all networks (same for volumes)

Overview of all commands

docker build         #builds a Docker image from a Dockerfile and context directory
docker run           #creates and starts a new container from a specified image
docker stop          #stops one or more running containers
docker ps            #lists all running containers
docker ps -a         #lists all containers, including stopped ones
docker rm            #removes one or more stopped containers
docker rmi           #removes one or more Docker images
docker pull          #downloads an image from a Docker registry to your local machine
docker push          #uploads an image to a Docker registry
docker images        #lists all Docker images on the local machine
docker exec          #runs a command inside a running container
docker logs          #fetches logs from a container
docker inspect       #shows detailed information about a container or image (in JSON format)
docker-compose       #defines and runs multi-container Docker apps using docker-compose.yml
docker network       #manages Docker networks (create, inspect, list, remove)
docker volume        #manages Docker volumes (create, inspect, list, remove)
docker system prune  #cleans up unused containers, images, volumes, and networks

About

Build a fully containerized WordPress + Nginx + MariaDB infrastructure from scratch using Dockerfiles and Docker Compose.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages