SkillAgentSearch skills...

Inception

School 42 inception project. Project + tutorial + bonus in my read.me

Install / Use

/learn @vbachele/Inception
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Inception

This project from 42 school aims to broaden your knowledge of system administration by using Docker. IIn this tutorial You will virtualize several Docker images, creating them in your new personal virtual machine. In this read.me you will have an inception tutorial to know how the project works.

Important things to read before beginning the project

  1. Don't try to do all the containers (Nginx, wordpress and mariaDB) at the same time. You will be lost and you will not understand properly how it works. Do it step by step.

  2. Begin with Nginx by displaying an index.html page

    • Learn first how to launch a docker image && to execute this image without using docker-compose
    • Learn How to display an html page on http://localhost:80"
    • Learn how to display an html page with SSL on http://localhost:443"
  3. Do wordpress

    • You can begin from here the docker-compose file, you don't need it before
  4. Finish with MariaDB.

You want to try if each container works in general? No worries, you will be able to do it by importing images for wordpress and mariaDB from the hub. (if you read this for the first time, I invite you to begin to read this beautiful READ.ME and put a star on it! It helps!)

  • The 2 github which helped me a lot for the project : llescure and malatini
  • This github which helped me for the bonus twagger

If you have questions: please contact me, I will be glad to give you an answer ! my discord username: vbachele#7949

SUMMARY

1. DEFINITIONS

2. DOCKER

3. NGINX

4. WORDPRESS

4. MARIADB

5. BONUS

Definitions

What is a docker ?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production. Docker provides the ability to package and run an application in a loosely isolated environment called a container.

What is a docker-compose ?

What is docker in general What is docker network Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

What is a docker-file ?

Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

How to install docker on MACOS

For this project, I am on my personal mac so I don't need to use the virtual machine to use a sudo command. I had to install docker. First, you need:

  • I went directly to the docker website and I downloaded docker Link to the website
  • I installed docker on the machine
  • I tested to run a dockerfile thanks to the command docker run hello-world

Useful things to know about inception dockers and containers

  • On the mac, Apache service is installed by default. I deleted Apache from my computer to avoid any problem with nginx
  • If you are at 42 on their computer you should stop these services which are running by default
sudo service nginx stop
sudo service mariadb stop
sudo service apache2 stop
sudo service mysql stop

DOCKER

Important commands to use docker

General docker commands

- docker ps or docker ps -a //show the names of all the containers you have + the id you need and the port associated.
- docker pull "NameOfTheImage" // pull an image from dockerhub
- docker "Three first letter of your docker" // show the logs of your last run of dockers
- docker rm $(docker ps -a -q) //allow to delete all the opened images
- docker exec -it "Three first letter of your docker" sh // to execute the program with the shell

Docker run

- docker run "name of the docker image" //to run the docker image
- docker run -d, // run container in background
- docker run -p,// publish a container's port to the host
- docker run -P, // publish all exposed port to random ports
- docker run -it "imageName", //le programme continuera de fonctionner et on pourra interagir avec le container
- docker run -name sl mysql, //give a name for the container instead an ID
- docker run -d -p 7000:80 test:latest

Docker image

- docker image rm -f "image name/id", //delete the image, if the image is running you need to kill it first.
- docker image kill "name", //stop a running image,

How to write a docker file

  • Create a filename dockerfile
  • Write your command inside the doc
  • Build the dockerfile with the command "docker build -t "nameYouChoose"."
  • Execute the dockerfile with the command: docker run "nameYouChoose"

Here are the most common types of instructions:

  • FROM <image> - defines a base for your image. exemple : FROM debian
  • RUN <command> - executes any commands in a new layer on top of the current image and commits the result. RUN also has a shell form for running commands.
  • WORKDIR <directory> - sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD instructions that follow it in the Dockerfile. (You go directly in the directory you choose)
  • COPY <src> <dest> - copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.
  • CMD <command> - lets you define the default program that is run once you start the container based on this image. Each Dockerfile only has one CMD, and only the last CMD instance is respected when multiple ones exist.

How to launch a localhost webpage to test

(this point works only on the mac and not the VM)

Watch this Video tutorial

  • Create a HTML file with some code in it.
  • Create you dockerfile
    • The image will be NGINX : FROM NGINX
    • Use COPY to copy your files into the html directory on NGINX
  • Use the command "docker build -t simple ."
  • Use the command "docker container run --name="nameofyourchoice" -d -p 9000:80 simple"
    • --name is to give a name to your image
    • -d run the container in background
    • -p publish the container's port to the host. In that case 9000 to 80

NGINX

How to set up NGINX (our web server)

  • Video tutorial Nginx is a webserver which stores hmtl, js, images files and use http request to display a website. Nginx conf documents will be used to config our server and the right proxy connexion.

configure .conf file on nginx

useful nginx links

Listen && Location

  • Listen will indicate to the server which request it has to accept: Listen can take ports and adresses : exemple Listen 80;
  • The location directive within NGINX server block allows to route request to correct location within the file system. The directive is used to tell NGINX where to look for a resource by including files and folders while matching a location block against an URL.

Steps to add in localhost by configuring

(this point works only on the mac and not the VM)

  1. I added to my /var/www/ directory an index html file
  2. I configured the default file in etc/nginx/site-enabled/default
  3. I added a server bracket with a location to var/www/ in the doc. Save it and reload nginx with 'nginx -s reload'.
  4. Because the port host I put when I built was 7000. Go to a web page and put: http://localhost:7000/. It works!!!! nginxLocalImage

How to change your localhost by vbachele.42.fr

  1. Go to the file /etc/hosts
  2. Add the following line : "127.0.0.1 vbachele.42.fr"

Fastcgi (or how to process PHP with nginx)

Useful links

  • [What is http](https://en.wikipedia.org/wi

Related Skills

View on GitHub
GitHub Stars251
CategoryDevelopment
Updated4d ago
Forks6

Languages

Dockerfile

Security Score

85/100

Audited on Mar 23, 2026

No findings