Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Solution: Run an Apache Container

Sumit Rawal answered on June 17, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Starting Apache...fail.
  • stop apache server
  • restart apache
  • linux apache stop
  • How to start apache2 server
  • stop apache service
  • kill apache Failed to restart apache: [apache]
  • apache 2 stop linux
  • ubuntu apache2 command
  • start apache service
  • restart apache
  • starting apache2 server
  • Finding Apache http Process
  • Start and Enable Apache
  • stop apache server
  • how to make apache not run automatically linux
  • attemting to start apache server
  • Exercise: Run an Apache Container
  • stop apache2 ubuntu

  • Solution: Run an Apache Container

    0

    Running an Apache container

    Creating a pod manifest file to run an Apache file is not much different than what we have seen before.

    Search in directory...

    /

    apache.yaml

    apache.yaml

    12345678

    apiVersion: v1

    kind: Pod

    metadata:

    name: apache

    spec:

    containers:

    - name: apache-container

    image: httpd

    Run

    Save

    Reset

    Your app can be found at: https://ed-5009147949744128_dc.educative.run

    Testing the Solution

    Note: Please run the above widget, and wait for the application to load before clicking on the above URL.

    In the apache.yaml file, we’re creating a pod named apache. We can name it whatever we want. But for this solution, we’re naming it “apache.” We can change the name of this pod in line 4. In line 7 and 8, we’re specifying the name and image of the container. We’re naming our container apache, and httpd is the name of the docker image that belongs to Apache.

    Let’s apply this manifest using the following command:

    kubectl apply -f apache.yaml

    Next, let’s check the pods we have running:

    kubectl get pods

    Once the pod is in the running state, we’ll use kubectl port-forward to send requests from localhost:3000 to the container’s port 80:

    kubectl port-forward apache 3000:80

    Note: We need to add the --address 0.0.0.0 flag to the above command to run it on this platform, so the above command would become: kubectl port-forward apache --address 0.0.0.0 3000:80. Or if you want to execute it with nohup, the updated command would be: nohup kubectl port-forward --address 0.0.0.0 apache 3000:80 > /dev/null 2>&1 &. Press Ctrl+D to exit out of the shell session.

    Now, if you access the URL in the SPA widget, you should see the default apache page.

    Default Apache page

    Now, let’s try to change the contents of the /usr/local/apache2/htdocs/index.html file. For this, we need to enter the container by running the following command:

    kubectl exec -it apache -- sh

    Once inside the container, we can change the contents of this file to whatever string we want. But for the sake of this example, let’s change it to “Welcome to Apache!” We can use the following command to do just that: 

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Jun 17 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.