Docker: Apache container

Running Apache in Docker from Ubuntu

Install Docker

curl -fsSL https://get.docker.com | sh

 

To allow you to use Docker as a user

sudo usermod -aG docker <username>

 

Run Docker with Apache image:

sudo docker run -dit –name apache -p 8080:80 -v /tmp/webroot:/usr/local/apache2/htdocs/ httpd:2.4

This will overwrite anything you’ve written to `local webroot path`.

Also, `8080:80` is `host:container`.

See also docker container run

 

And `docker stop <your container name>` will not delete that volume. It persists.

https://docs.docker.com/storage/

 

Test from local machine with:

curl localhost:8080

 

Note: you can access your container ID if you know the container name. E.g. assuming the container name is apache then you can use:

`APP_ID=docker ps | grep apache | awk ‘{print $1}’`

 

Leave a Reply

Your email address will not be published. Required fields are marked *