A 42 project aimed at learning Docker and Docker-compose. This project asks us to create a small network of 3 Docker containers, one containing Nginx, one containing Wordpress and the third containing MariaDB. All three must work together over the Docker network to display a local website.
Finished 06/10/2023. Grade: 100%
Launching this project requires a bit of setup:
- Clone this repository and
cd
into it. - In the
srcs
folder, there is anExampleEnvFile
that must be filled out and saved intosrcs/.env
- The Makefile has a
login
variable that should be edited to reflect your 42 school login
Once these steps are complete, you can use make
to build and launch the docker containers.
The website should be viewable at the adresses https://localhost
or http://login.42.fr
(replacing your login with the value in the Makefile variable).
- Show Docker images:
docker images
- Show Docker containers:
docker ps
(add-a
option to view stopped/exited containers) - Show Docker volumes:
docker volume ls
(docker volume inspect <volume name>
to view more information about the volume) - Show Docker networks:
docker network ls
- Show logs:
docker-compose logs
(add--follow <container name>
option to only see that container's logs) - Run a container in interactive mode:
docker run -it <image ID>
- Execute a command inside a running container:
docker exec <container name> <command>
- Execute a command inside a running container in interactive mode:
docker exec -it <container name> <command>
- Execute an interactive shell inside a running container:
docker exec -it <container name> sh
(This shows that Docker containers are not secure, since we can easily get a shell as root)
FROM
: Downloads an image to use as the container's base. Here we are using Alpine:3.18.RUN
: Runs the specified command during the building process. Useful for installing binaries for later use.COPY
: Copy a file from host machine to the future docker container. Useful for loading custom configuration files.EXPOSE
: Expose a port so that it is accessible from outside the Docker network.ENTRYPOINT [ "command", "args"]
: The command to run at conainer startup.
Docker:
Alpine Linux:
Nginx:
- NGINX Configuration Beginner's Guide
- OpenSSL Man Page
- Generate Self-Signed SSL Certificate with OpenSSL
MariaDB:
- How do I find the MySQL my.cnf location
- How to Install and Configure Mariadb
- Configuring MariaDB with Option Files
- MariaDB Server System Variables
- Configuring MariaDB for Remote Client Access
- How to Allow Remote Access to MariaDB in Ubuntu Linux
WordPress:
Made by mcombeau: [email protected] | LinkedIn: mcombeau | Website: codequoi.com