Giter Club home page Giter Club logo

inception's Introduction

inception

1337 project, setup of a small infrastructure with docker-compose. Services include an nginx, Wordpress and a MariaDB database. When you run make the scripts build the custom Docker images for each of those, before deploying and establishing a connection between all of them with a custom yaml file.

Notes

Docker vs Docker-compose

Docker is simply a software that allow users to run lightweight virtual machines. Docker-compose is a Yaml file consisting of all the details regarding various services, netwroks and volumes that are needed for setting up the application. It is used for creating multiple containers, host them and establish communication between them.

Container terminology

Container is two different things. Like a normal Linux program, containers have two states -rest and running. When at rest, a container is a set of files that is saved on the desk (container image). Once running, containers are just a linux process.

Docker is a container engines that takes a container image and turn it into a container(running process).

Container Image is a file which can be pulled down from a registry server(DockerHub) or created from scratch. It contains all dependecies and configuration to run a program.

Registry server is a fancy file server that is used to store docker repositories.When a docker daemon does not have a locally cached copy of a repo, it will automatically pull it from a registry server.

Basic commands of docker && docker-compose

docker container run #starts a new container
docker container start #start an existing stopped one
docker logs #shows logs for a specific container
docker container rm #remove one or more containers
docker list #list running processes in specific container
ps aux #show all runing processes

docker-compose up #it builds the images if they are not located locally and starts the containers
docker-compose ps #list all the containers in the current docker-compose file.
docker-compose down #it stops all the services and cleans up the containers, netwroks and images.

Docker network

To make containers connect to each other and share files and ressources we should create a network.There are various kinds of netwrok drivers : bridge, overlay. Bridge driver is limited to local.

By dfault, the container is assigned an IP address for every docker netwrok it connects to. The IP address is assigned from the pool; assigned to the netwrok. The docker daemon acts as a DHCP server for each container. Each network has a default subnet mask and a gateway. Whenever a containr is restarted a new IP adress is assigned to the container.

Docker secures the network by managing rules to block connectivity between different docker networks and that's why we need to expose ports for external access.

php FastGCI Process Manager

PHP-FPM is an acronym for FASTCGI process Manager.It's an interface allowing communication between nginx and php.

To connect Nginx to PHP-FPM unix or TCP/IP socket Nginx sends FastCGI requests to PHP-FPM. to make that happens, PHP-FPM can either listen on a TCP/IP socket or unix domain. using the fastcgi_pass directive.

Unix Domain are meant for inter-process communication that allow data exchange between processes running on the same operating system. TCP/IP allow connection between PHP-FPM and NGINX even if they are running on different systems.

To configure PHP-FPM to listen address modify www.conf to define the address he gonna listens through. configure nginx to work with php-fpm app server via the same address using fastcgi_pass configuration parameter.

Docker volume

Let's suppose that we have a database container and the container has a virtual file system where the data is usually stored. But, when I want to remove or restart the container the data in this virtual file system is removed and gone.

Volume is the preferred mechanism for persisting data generated by and used by Docker containers. It is a folder in phisycal host file system which is mounted into the virtual file system of docker.

Useful links

Docker guide

Docker-compose tutorial

Connect nginx to php

Port binding

Configure remote access to MariaDB

Docker-compose volume and networks

inception's People

Contributors

framdani avatar

Stargazers

Oumaima EL YOUSSEFI avatar Boutzougarte walid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.