Friday, September 10, 2021

Apache on Ubuntu

Dockerfile for installing Apache on Ubuntu:

FROM ubuntu:20.04

ENV TZ=Europe/Berlin

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get -y install apache2

EXPOSE 80

CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]

Build and run

docker build -t ubu-apache .
docker run --name=ubu-apache -d -p 80:80 -v $(pwd)/html/:/var/www/html/ ubu-apache

Enter in container. Tail logs and list files in html folder

docker exec -it ubu-apache /bin/bash

root@8c138884f9a3:/# tail -f /var/log/apache2/error.log

root@8c138884f9a3:/# tail -f /var/log/apache2/access.log

root@8c138884f9a3:/# ls -l /var/www/html