{"id":22962103,"url":"https://github.com/actionanand/laravel_with_docker","last_synced_at":"2026-04-09T18:55:39.590Z","repository":{"id":214543887,"uuid":"736777960","full_name":"actionanand/laravel_with_docker","owner":"actionanand","description":"Creating laravel project without installing anything in host machine with the help of docker.","archived":false,"fork":false,"pushed_at":"2023-12-31T17:42:02.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T03:28:29.639Z","etag":null,"topics":["artisan","composer","docker","docker-compose","laravel","mysql","php"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/actionanand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-28T21:10:54.000Z","updated_at":"2023-12-29T18:37:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"2316566e-b4ab-40df-8d61-1f7e2585b10d","html_url":"https://github.com/actionanand/laravel_with_docker","commit_stats":null,"previous_names":["actionanand/laravel_with_docker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/actionanand/laravel_with_docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actionanand%2Flaravel_with_docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actionanand%2Flaravel_with_docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actionanand%2Flaravel_with_docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actionanand%2Flaravel_with_docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/actionanand","download_url":"https://codeload.github.com/actionanand/laravel_with_docker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actionanand%2Flaravel_with_docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275319890,"owners_count":25443827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artisan","composer","docker","docker-compose","laravel","mysql","php"],"created_at":"2024-12-14T19:15:19.729Z","updated_at":"2025-09-15T20:44:27.008Z","avatar_url":"https://github.com/actionanand.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel with Docker (Section 6)\r\n\r\nCreating laravel project without installing anything in host machine with the help of docker.\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/3436131f-21ad-4ef4-8f9a-812e22f34b7f)\r\n\r\n### Application Containers\r\n\r\n* `src`: some folder, on our host machine, contains source code of this laravel php app.\r\n* php Interpreter (`php` service in our code) container: The `src` folder will be exposed to this. This will interpret the php code (src) code and generate response to the incoming request.\r\n* `nginx`: This web server will take all incoming request. And go to php Interpreter \u0026 let php interpreter generate response.And send back to the client.\r\n* `sql`: For storing DB. php Interpreter, in the end, needs to communicate with sql.\r\n* Application Conatiners need to be up always.\r\n\r\n### Utility Containers\r\n\r\n* `Composer`: Composer to php is like what is `npm` to node. This is a package manager which we can use to install third party packages. We'll use composer to create laravel application. And laravel will use composer to install third party dependencies.\r\n* `Laravel Artisan`: Laravel ships its own tool, `Artisan` along with php. This is for run migration against the DB and to write initial data to db.\r\n* `npm`: Laravel uses `npm` for some frontend logics.\r\n\r\n## Creating A Laravel Project\r\n\r\n[Creating A Laravel Project - Guide](https://laravel.com/docs/10.x#creating-a-laravel-project)\r\n\r\n```bash\r\ndocker-compose run --rm composer create-project laravel/laravel .\r\n```\r\n\r\n* `.` referes to the current folder. So files will be generated in current folder.\r\n* The above command will generate laravel code in `src` folder of our host machine.\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/33245990-c426-481e-b235-d295cabd695b)\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/aa7fda0b-6861-40e8-a0c5-796376fc96bd)\r\n\r\n* Change the `DB_HOST` value as `mysql` in side the `.env`, found inside `src` folder as for inter-docker communication, if all the containers are under same network, we can replcae `localhost` by `container_name` (here `service_name` as we use `docker-compose`). And change the username, password and database name too as shown below. These values we can find under `env/mysql.env`.\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/10e24b78-f78e-4b10-9265-349fc6c2e8b9)\r\n\r\n## Bringing up the laravel project \r\n\r\n```shell\r\ndocker-compose up -d service1 service2 service3 etc\r\n```\r\n\r\n```bash\r\ndocker-compose up -d server php mysql\r\n```\r\n\r\n* If we added `depends_on` property under the service `server` with `php` and `mysql` in `docker-compose.yaml`, the command to bring up the services is as follow:\r\n\r\n```bash\r\ndocker-compose up -d --build server\r\n```\r\n* `--build` is to rebuild everytime whenever we run the above command, or cached image only will be taken.\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/344868c8-3c48-428b-9e75-7ee00ca7a34a)\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/13432b23-5fed-4354-88f4-ba548b2250dd)\r\n\r\n### Other userful info.\r\n\r\n* Running containers\r\n\r\n ![image](https://github.com/actionanand/docker_playground/assets/46064269/6c8b89db-ab1a-498c-881c-63b4f8920895)\r\n\r\n* Built/pulled Images\r\n\r\n ![image](https://github.com/actionanand/docker_playground/assets/46064269/c69169ce-34df-4934-9d80-e1f3f474756b)\r\n\r\n * Generated networks\r\n\r\n ![image](https://github.com/actionanand/docker_playground/assets/46064269/1cd217ad-4442-465c-a4b3-cebbe3a810d4)\r\n\r\n### Output\r\n\r\n* Point your browser to `localhost:8000`\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/c96aaded-92c6-4f1c-81bf-359e05be7850)\r\n\r\n### Bringing down the docker services\r\n\r\n```shell\r\ndocker-compose down\r\n```\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/d2b769a4-d27b-4396-92a3-5337258ae230)\r\n\r\n### Checking the db connection and running migrations\r\n\r\n![image](https://github.com/actionanand/docker_playground/assets/46064269/a046c7c4-1a52-4285-b7c1-9040ec320365)\r\n\r\n### Fixing error if happens\r\n\r\nWhen using Docker on Linux, you might face permission errors when adding a bind mount.\r\nIf you happens, try these steps:\r\n\r\n* Change the `php.dockerfile` so that it looks like that:\r\n\r\n```dockerfile\r\nFROM php:8.3.1-fpm-alpine\r\n \r\nWORKDIR /var/www/html\r\n \r\nCOPY src .\r\n \r\nRUN docker-php-ext-install pdo pdo_mysql\r\n \r\nRUN addgroup -g 1000 laravel \u0026\u0026 adduser -G laravel -g laravel -s /bin/sh -D laravel\r\n \r\nUSER laravel\r\n```\r\n\r\n* Please note that the `RUN chown` instruction was removed here, instead we now create a user **laravel** which we use (with the `USER` instruction for commands executed inside of this image / container).\r\n\r\n* Also edit the `composer.dockerfile` to look like this:\r\n\r\n```dockerfile\r\nFROM composer:2.6.6\r\n \r\nRUN addgroup -g 1000 laravel \u0026\u0026 adduser -G laravel -g laravel -s /bin/sh -D laravel\r\n \r\nUSER laravel\r\n \r\nWORKDIR /var/www/html\r\n \r\nENTRYPOINT [ \"composer\", \"--ignore-platform-reqs\" ]\r\n```\r\n\r\n* Here, we add that same **laravel** user and use it for creating the project therefore.\r\n\r\n* These steps should ensure that all files which are created by the Composer container are assigned to a user named **laravel** which exists in all containers which have to work on the files.\r\n\r\n* Resolving permision issue\r\n\r\n```dockerfile\r\nRUN chown -R www-data:www-data /var/www\r\nRUN chmod 755 /var/www\r\n```\r\n\r\n## Associated repos:\r\n\r\n1. [Docker Basics](https://github.com/actionanand/docker_playground)\r\n2. [Managing Data and working with volumes](https://github.com/actionanand/docker_data_volume)\r\n3. [Docker Communication](https://github.com/actionanand/docker_communication)\r\n4. [Docker Multi-container with docker-compose](https://github.com/actionanand/docker_multi-container)\r\n5. [Docker Utility Containers \u0026 Executing Commands](https://github.com/actionanand/node-util)\r\n6. [Laravel with Docker](https://github.com/actionanand/laravel_with_docker)\r\n7. [Angular with Docker](https://github.com/actionanand/angular_with_docker)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factionanand%2Flaravel_with_docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factionanand%2Flaravel_with_docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factionanand%2Flaravel_with_docker/lists"}