Skip to content
Iva edited this page Aug 23, 2024 · 8 revisions

Nginx Docker

  • Initial Configuration for NGINX

    • Create the compose file docker-compose.yml in the path described below via the terminal:

      mkdir -p rootInception/srcs/docker-compose.yml
    • Create the docker image configuration file Dockerfile for NGINX in the path described below via the terminal:

      mkdir -p rootInception/srcs/requirements/nginx/Dockerfile
    • Fill in the docker-compose.yml so that when executed, it can compose the NGINX container as shown below:

      version: "3.8"
      
      services:
        nginx:
          build: requirements/nginx/.
          container_name: nginx
          ports:
            - "80:80"
    • Fill in the Dockerfile for NGINX so that it can configure a docker image

      FROM debian:bullseye 
      RUN apt update && apt upgrade -y && apt install -y nginx
      ENTRYPOINT ["nginx", "-g", "daemon off;"]

      👉🏼 These are the minimum configurations for NGINX to run inside the container. We now need to test if NGINX is running correctly and if we can access it through the browser on our host/physical machine.

    Testing initial config to nginx

    • Execute the command that will create the NGINX container and start it, as described below, via the terminal:

      docker compose up --build
    • Enter the URL http://127.0.0.1/ or http://localhost in your preferred browser to test NGINX.

      👉🏼 Upon confirming the address with ENTER, the browser is expected to display a default NGINX welcome page, confirming that the test passed and that NGINX is now running in the container.

    ⏮️ Previous
    Next ⏭️

Clone this wiki locally