Search code examples
apachedockerdocker-machine

How to access Apache2 container working directory in order to change the content of default html?


I have installed apache2 container using docker as below

docker run -d -p 80:80 --name apache  httpd:2.4

apache server is running and I am able to see below screen.

apache ok

But how do I change the content of above screen?


Solution

  • You need to first get inside the image

    docker exec -it apache bash
    

    If bash is not there then use sh. After that you need to have a editor installed inside

    apt-get update && apt-get install -y nano
    
    nano index.html
    

    And then you can change the content

    Edit-1: Files in container

    To copy the files you the running container you need to do it like below

    docker cp /home/ubuntu/docker-work/sample.html apache:/usr/local/apache2/htdocs/