I have created my Dockerfile and docker-compose.yaml.
When I run the command:
docker-compose up -d
Everything is fine, This builds the image of laravel application and runs the container. The problem is that when I try to access the application through browser. I get nothing but blank white page.
But again if i run the command:
docker run -d -p 8000:40 myImage
My application runs smoothly, after accessing http://localhost:8000
My docker-compose.yaml file is like this:
version: ‘3.3’
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
image: ‘myImage’
ports:
- 8888:80
volumes:
- ./laravel-app:/var/www/html
db:
image: mysql:5.7
restart: always
ports:
- “3333:3306”
environment:
MYSQL_DATABASE: ‘laravel-app’
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_ROOT_PASSWORD: “”
volumes:
- ./laravel-app/db:/var/lib/mysql
My Dockerfile is like this:
FROM link-to-my-image
USER root
WORKDIR /var/www/html
RUN apt-get update && apt-get install -y
libpng-dev
zlib1g-dev
libxml2-dev
libzip-dev
libonig-dev
zip
curl
unzip
&& docker-php-ext-configure gd
&& docker-php-ext-install -j$(nproc) gd
&& docker-php-ext-install pdo_mysql
&& docker-php-ext-install mysqli
&& docker-php-ext-install zip
&& docker-php-source deleteCOPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN curl -sS https://getcomposer.org/installer | php – --install-dir=/usr/local/bin --filename=composer
RUN chown -R www-data:www-data /var/www/html
&& a2enmod rewrite
docker-compose up -d (white page when I access: localhost:8888)
docker run -d -p 8000:40 myImage (works fine when I access: localhost:8000)