it seems the apache is not listening on the port you want (8080), it defaults to 80 and in the config you are not changing it (forgive me if incorrect, not a docker pro😅). i see you set the PORT env variable, but couldnt find whether it is really used or not. according to a github discussion, it isn't. this is it and it might help: https://github.com/docker-library/php/issues/1030
Fresh install of laravel 11 with Dockerfile locally does not show laravel page
I'm mostly following a guide to dockerize and locally run a fresh install of the Laravel app but when I try localhost:8080 I get ERR_EMPTY_RESPONSE
I got a fresh Laravel install from: composer create-project --prefer-dist laravel/laravel my-laravel-app-1
where running $ php artisan --version returns Laravel Framework 11.35.1
My Dockerfile
FROM php:8.2-apache
WORKDIR /var/www/html
COPY composer.lock composer.json ./
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
lua-zlib-dev \
libmemcached-dev libonig-dev \
libzip-dev
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && docker-php-ext-install gd
COPY . .
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
RUN chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
RUN curl -sS <composer installer link> | php -- --install-dir=/usr/local/bin --filename=composer
RUN useradd -G www-data,root -u 1000 -d /home/devuser devuser
RUN mkdir -p /home/devuser/.composer && \
chown -R devuser:devuser /home/devuser
RUN composer install #--no-dev --no-interaction --prefer-dist --optimize-autoloader
RUN php artisan config:clear
EXPOSE 8080
CMD bash -c "php artisan config:clear && apache2-foreground"
And for the docker commands I ran
docker build -t my-laravel-app-1 .
docker run --init -d -e PORT=8080 -p 8080:8080 my-laravel-app-1
So when I run docker container ls I get
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d601e608d71a my-laravel-app-1 "docker-php-entrypoi…" 9 minutes ago Up 9 minutes 80/tcp, 0.0.0.0:8080->8080/tcp confident_ptolemy
Which looks right to me but I keep getting empty responses at localhost:8080.
Is that expected for a fresh Laravel install? I was expecting the Laravel page.
Any help would be greatly appreciated!
Please or to participate in this conversation.