@darrion.kuhn
To run a Laravel app inside a Docker container, follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# Use the official PHP image as the base image FROM php:7.4-fpm # Set the working directory inside the container WORKDIR /var/www/html # Install dependencies RUN apt-get update && apt-get install -y git zip unzip # Install PHP extensions RUN docker-php-ext-install pdo_mysql # Install Composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Copy the Laravel application files to the container COPY . . # Install Laravel dependencies RUN composer install # Expose port 8000 to access the Laravel app EXPOSE 8000 # Run the Laravel application CMD php artisan serve --host=0.0.0.0 --port=8000 |
1
|
docker build -t my-laravel-app . |
1
|
docker run -p 8000:8000 my-laravel-app |
Your Laravel app should now be up and running inside a Docker container.