# Using Laravel and Docker by Timo Stankowitz The latest version of Laravel with Apache webserver in just one Docker container. If you have any questions of any suggestions just reach out to me. ## Create a new project with composer Don't create an extra directory. Comperser will do this for you. The folder name will be *project-name* (change to your actual project name). Make sure you have the latest version of the composer docker image: `docker pull composer` `docker run -u 1000 --rm -v $(pwd):/app composer create-project --prefer-dist laravel/laravel *project-name*` This can take up to 5 minutes. ## start your application with artisan The simplest way is to create a `Dockerfile` in you root directory with `touch Dockerfile`. Copy and paste the following content: ``` FROM php:7.4-apache LABEL maintainer="Timo Stankowitz " RUN a2enmod rewrite COPY config/apache.conf /etc/apache2/sites-available/000-default.conf RUN rmdir /var/www/html COPY ./ /var/www/ # update permission RUN chown -R www-data: /var/www/bootstrap/cache/ RUN chmod -R 777 /var/www/storage/ RUN chmod -R 777 /var/www/bootstrap/cache/ ``` ### Create `docker-compose.yml` Replace *project-name* with your actually project name. ``` version: '3' services: project-name: image: php:7.4 networks: - project-name ports: - 80:8000 working_dir: "/mount" entrypoint: ["php", "artisan", "serve", "--host=0.0.0.0"] volumes: - ./:/mount networks: project-name: driver: bridge ipam: driver: default config: - subnet: 172.29.1.0/24 ``` and run `docker-compose up` Open a webbrowser and open [localhost](http://localhost)