PHPackages                             vivasoft/laravel-docker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. vivasoft/laravel-docker

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

vivasoft/laravel-docker
=======================

If you want to use docker with your laravel project, this package will help you to create the container. It contains most of the require software to run a laravel application; it also provides flexibility to customize your container based on your need.

52572PHP

Since Jan 11Pushed 5y ago4 watchersCompare

[ Source](https://github.com/vivasoft-ltd/laravel-docker)[ Packagist](https://packagist.org/packages/vivasoft/laravel-docker)[ RSS](/packages/vivasoft-laravel-docker/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Docker
--------------

[](#laravel-docker)

[Vivasoft Ltd](http://www.vivasoftltd.com)

If you want to use [docker](https://www.docker.com) with your laravel project, this package will help you to create the container. It contains most of the require software to run a laravel application; it also provides flexibility to customize your container based on your need.

Table of contents
-----------------

[](#table-of-contents)

- [Prerequisite](#prerequisite)
- **Installation &amp; Setup:**
    - **Install:**
        - [With a new project](#use-with-new-laravel-installation)
        - [Or, into an existing project](#use-with-existing-project)
    - [Update `.env` file](#update-env-file)
- **Docker Compose Settings:**
    - [PHP](#php)
    - [Database](#database)
    - [Nginx](#nginx)
    - [Redis](#redis)
- **Daily Usages:**
    - [Connecting Via SSH](#connecting-via-ssh)
    - [Running `php artisan` command](#running-php-artisan-command)
    - [Connect To Database](#connect-to-database)
- [Advance Usages](#advance-usages)
- [Troubleshooting](#troubleshooting)
- [Deployment](#deployment)
    - \[AWS\]
    - \[Linode\]
    - \[Digital Ocean\]

Prerequisite
------------

[](#prerequisite)

- Docker Engine &gt;= 17.04.0

Use with new laravel installation
---------------------------------

[](#use-with-new-laravel-installation)

---

**\#Installation Process:**

**Youtube link:**

---

**Step 1:**
Open your terminal, navigate to your project directory and run the following command to install the latest version.

```
docker run --rm --interactive --tty --volume ${PWD}:/app composer create-project --prefer-dist laravel/laravel .
```

**Step 2:**
Install `vivasoft/laravel-docker` package using the following command:

```
docker run --rm --interactive --tty --volume ${PWD}:/app composer require vivasoft/laravel-docker:dev-master
```

**Step 3:**
Run the following command to publish your docker files into your root project directory.

```
docker run --rm --interactive --tty --volume ${PWD}:/app composer php artisan vivasoft:dockerInstall
```

A new folder `.docker` along with two other files `docker-compose.yml` and `Dockerfile` should copy to your root installation directory.

---

**NOTE**

Before building the docker image you should update your [database](#database) credential.

For [advanced usages](#advance-usages) you may want to update your [nginx](#nginx) configuration.

---

**Step 4:**
Run the application:

```
docker-compose up -d
```

It may take some time, so grab a cup of ☕ 😬

When done - [update your `.env` file](#update-env-file) and visit your IP address: http://your\_ipaddress:port \[default is: 80\]

Use with existing project
-------------------------

[](#use-with-existing-project)

**Step 1:**
Install `vivasoft/laravel-docker` package:

```
composer require vivasoft/laravel-docker:dev-master
```

**Step 2:**
Publish docker components by running the following command:

```
php artisan vivasoft:dockerInstall
```

A new folder `.docker` along with two other files `docker-compose.yml` and `Dockerfile` should copy to your root installation directory.

---

**NOTE**

Before building the docker image you should update your [database](#database) credential.

For [advanced usages](#advance-usages) you may want to update your [nginx](#nginx) configuration.

---

**Step 3:**
Run the application:

```
docker-compose up -d
```

When done - [update your `.env` file](#update-env-file) and visit your IP address: http://your\_ipaddress:port \[default is: 80\]

Update `.env` file
------------------

[](#update-env-file)

Open your `docker-compose.yml` file and use the related value.

Suppose your `docker-compose.yml` settings:

```
  #MySQL
  db:
    image: mysql:5.7.28
    container_name: db
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: one_database
      MYSQL_ROOT_PASSWORD: root
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - dbdata:/var/lib/mysql
      - ./.docker/mysql/my.cnf:/etc/mysql/my.cnf
    networks:
      - app-network
```

In your `.env` file you have to update the following value:

The `DB_HOST` should be the `container_name` of your `#MySQL Container`.
The `DB_DATABASE` should be same as `MYSQL_DATABASE`.
The `DB_PORT` should be same as `3306`.
The `DB_PASSWORD` should be same as `MYSQL_ROOT_PASSWORD`.

See the [advanced usages](#database) section for more options.

**EXAMPLE**

BEFORE UPDATE:

```
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
```

AFTER UPDATE:

```
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=one_database
DB_USERNAME=root
DB_PASSWORD=root
```

PHP
---

[](#php)

Default `PHP` settings:

```
  #PHP
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: vivasoft/php
    container_name: app
    restart: unless-stopped
    tty: true
    environment:
      SERVICE_NAME: app
      SERVICE_TAGS: dev
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./.docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - app-network
```

- **`php.ini:`** you can modify or add any settings on your host machine's `.docker/php/local.ini` file and it should apply the changes on your application.
- **`Dockerfile:`** contains all the require tools to build the `vivasoft/php` image. If you need any **additional piece of software** or another **php extension** you can easily add them in this file. See the [official documentation](https://docs.docker.com/engine/reference/builder/) for more information. After modifying the file you have to [rebuild](#advance-usages) the image.

Database
--------

[](#database)

**Default** settings:

```
  #MySQL
  db:
    image: mysql:5.7.28
    container_name: db
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: one_database
      MYSQL_ROOT_PASSWORD: root

      MYSQL_USER: homestead
      MYSQL_PASSWORD: secret

      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - dbdata:/var/lib/mysql
      - ./.docker/mysql/my.cnf:/etc/mysql/my.cnf
    networks:
      - app-network
```

- You can use more `environment` variables. `MYSQL_USER` and `MYSQL_PASSWORD` are most important among them.

See more option on [docker mysql official](https://hub.docker.com/_/mysql) page.

Nginx
-----

[](#nginx)

**Default** settings:

```
  #Nginx
  webserver:
    image: nginx:latest
    container_name: webserver
    restart: unless-stopped
    tty: true
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./:/var/www
      - ./.docker/nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - app-network
```

**Run application into another ports:** update the `docker-compose.yml` file.

```
  #Nginx
  webserver:
    ...
    ports:
      - "NEW_PORT:80"
      - "443:443"
    ...
```

**Add SSL Certificate**: Coming Soon.

Redis
-----

[](#redis)

Connecting via SSH
------------------

[](#connecting-via-ssh)

When your container up and running. You can SSH into your container by using the following command:

```
docker exec -it CONTAINER_NAME bash
```

Running `php artisan` command
-----------------------------

[](#running-php-artisan-command)

There are two options to execute your `php artisan` command.

**Option 1**:
Run the following command from your project root directory.

```
docker-compose exec app php artisan
```

**n.b:** `app` is name of your PHP container.

**Option 2**: [SSH](#connecting-via-ssh) into your PHP container then run `php artisan`

Connect To Database
-------------------

[](#connect-to-database)

See [Update `.env` file](#update-env-file) section for current settings:

The `DB_HOST` should be your **IP Address**
The `DB_DATABASE` should be `MYSQL_DATABASE`.
The `DB_PORT` should be same as `3306`.
The `DB_USERNAME` should be `MYSQL_ROOT_PASSWORD` or `MYSQL_USER`
The `DB_PASSWORD` should be `MYSQL_ROOT_PASSWORD` or `MYSQL_PASSWORD`.

Advance Usages
--------------

[](#advance-usages)

**Rebuilding Image:**

- You can rebuild the image using `docker-compose up -d --build` command.

**Coming Soon**

Troubleshooting
---------------

[](#troubleshooting)

- **Command Prompt for Windows User**:
    - Windows user should use **Power Shell**.
    - If you want to use command prompt instead of **Power Shell**, you have to specify the **path** e.g: "(c:\\User\\ProjectPath)" instead of `${PWD}`.
- **Got permission denied while trying to connect to the Docker daemon socket**
    - [See Digital Ocean Community Answer](https://www.digitalocean.com/community/questions/how-to-fix-docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket)
- **PORT Binding Error**:
    - Open `docker-compose.yml` file and update `host` machine port. (Example: See [nginx](#nginx) run application into another ports.)

Deployment
----------

[](#deployment)

**Coming Soon**

Contributor
-----------

[](#contributor)

- [Faisal Islam](https://github.com/nscreed)
- [Sazedul Islam](https://github.com/sazid1462)

License
-------

[](#license)

The Vivasoft Laravel Docker is licensed under the terms of the [MIT License](https://github.com/vivasoft-ltd/laravel-docker/blob/master/LICENSE)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/62206f78e2e093ab8eeb5a439b1ab8606bedfe1bd8619c33802cd51dda980a5c?d=identicon)[nscreed](/maintainers/nscreed)

---

Top Contributors

[![faisalvs](https://avatars.githubusercontent.com/u/93644923?v=4)](https://github.com/faisalvs "faisalvs (9 commits)")[![nscreed](https://avatars.githubusercontent.com/u/10841057?v=4)](https://github.com/nscreed "nscreed (1 commits)")

### Embed Badge

![Health badge](/badges/vivasoft-laravel-docker/health.svg)

```
[![Health](https://phpackages.com/badges/vivasoft-laravel-docker/health.svg)](https://phpackages.com/packages/vivasoft-laravel-docker)
```

###  Alternatives

[deployer/deployer

Deployment Tool

11.0k25.4M207](/packages/deployer-deployer)[appwrite/server-ce

End to end backend server for frontend and mobile apps.

55.3k84.2k](/packages/appwrite-server-ce)[pragmarx/health

Laravel Server &amp; App Health Monitor and Notifier

2.0k1.0M2](/packages/pragmarx-health)[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22476.7M6](/packages/felixfbecker-language-server-protocol)[heroku/heroku-buildpack-php

Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP and Apache2/Nginx as on Heroku

8161.3M10](/packages/heroku-heroku-buildpack-php)[tiamo/phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard

4674.7k](/packages/tiamo-phpas2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
