1-1 For which reason is it better to run the container with a flag -e to give the environment variables rather than put them directly in the Dockerfile?
Passing environment variables with the -e flag when running a container is more secure, flexible, and reusable than hardcoding them in the Dockerfile. It allows for better security of sensitive data, easier updates, and simplifies managing configurations across different environments.
Volumes allow data to survive container restarts, upgrades, or recreations, ensuring data durability and backup capability. so we need a volume because when we stop the data we ensure that the data won't get lost
Run the Postgres container with environment variables and volume docker run -d --name my-postgres-container --network app-network -e POSTGRES_USER=usr -e POSTGRES_PASSWORD=pwd -e POSTGRES_DB=db -v pgdata:/var/lib/postgresql/data postgres
View logs to see if there is any problem docker logs my-postgres-container
To separate the build environment (we used maven) from the final runtime environment, making the final image smaller and more secure. so we have two stages the build one and the runtime
We need it to Keeping your backend safe and hiding its address, sharing the work between several servers, sending requests to the right service under one website, making pages load faster with caching and compression, giving users one easy address to access everything.
Docker Compose allows you to define and manage multiple related containers easily using a single YAML file.
docker-compose up -d — start in detached mode. docker-compose down — stop and remove containers, networks. docker-compose build — build or rebuild images. docker-compose logs — view logs from services. docker-compose ps — list running containers.
Defines three services, shared network, and persistent volume for Postgres data. It makes the connection between the the three services database, backend and the httpd. we give where they are build, container name , the depends_on, the port and the network it's on.
I looked wich images I needed with : docker images then Tag the images for Docker Hub : docker tag image username/repository:tag Login to Docker Hub : docker login Push the image to Docker Hub : docker push username/repository:tag
To share images with others or between environments. Enables continuous integration/deployment workflows. Provides a central storage for versioned images. Simplifies deployment to production or cloud environments. Ensures consistency across developer machines and servers.
Docker-based test environments for integration testing, making your tests more realistic and reliable.
It's used to secure and protect sensible data in a automized process
we put needs on a job to make it dependent on the successful completion of the build-and-test-backend job.
We push Docker images to a remote registry to make them accessible from any environment or machine. This allows other developers, servers, or deployment pipelines to pull and run the exact same container, ensuring consistency and reproducibility across development, testing, and production environments. Without pushing, the image remains local and cannot be reused elsewhere.
Test the connexion : ansible all -i inventories/setup.yml -m ping get the explotation system of the serveur : ansible all -i inventories/setup.yml -m setup -a filter=ansible_distribution*" desinstall Apache2 :ansible all -i inventories/setup.yml -m apt -a "name=apache2 state=absent" --become
The playbook installs and configures Docker on all target servers using a dedicated role called docker. It runs with administrative privileges, gathers system information, and delegates all tasks—such as installing dependencies, adding Docker’s repository, and starting the Docker service—to the role. This structure ensures the playbook is clean, reusable, and easy to maintain.
In this project, each docker_container task is responsible for launching a specific component of the application (proxy, backend, or database). These tasks define the container name, the image to run, the networks to connect to, and optionally ports to expose and environment variables.