1

I am new in Docker and I have installed apache from the image httpd:2.4 and name tecmint-web. I am trying to configure apache but I have no idea how to do it. I tried the following steps:

docker exec -it tecmint-web /bin/bash

ls

cd conf

ls

And the ouput of the ls is : extra httpd.conf magic mime.types original When I try to open httpd.conf with an editor, an error appears : command not found

I am doing anything wrong? How is it possible to configure apache?

3
  • with an editor what editor are you trying to use? Feb 1 at 11:06
  • 1
    the correct way to configure apache in docker is as documented Feb 1 at 11:22
  • In general, you do not start a container and start interactively changing config files. You create the config before hand and mount it into the container.
    – Panki
    Feb 1 at 14:38

1 Answer 1

0

According to the documentation of the official Docker image, to configure the Apache HTTP server, you can:

  1. Copy the configuration file from the image to your host with:
docker run --rm httpd:2.4 cat /usr/local/apache2/conf/httpd.conf > my-httpd.conf
  1. Edit locally the my-httpd.conf

  2. Build a new image, with the modified configuration file:

The Dockerfile:

FROM httpd:2.4
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf

Build the image with:

docker build -t my-configured-http-server .

You can also use Docker Compose with the original image and a mapped configuration file:

The docker-compose.yml file:

version: '3'

services:
  my-http-server:
    image: httpd:2.4
    volumes:
      - ${PWD}/my-httpd.conf:/usr/local/apache2/conf/httpd.conf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .